Skip to content

Commit

Permalink
Merging pull request #19 from stevenvolckaert/vNext
Browse files Browse the repository at this point in the history
Merging vNext into master.
  • Loading branch information
stevenvolckaert committed Nov 25, 2017
2 parents 900bb69 + 5e0a9e5 commit d093570
Show file tree
Hide file tree
Showing 12 changed files with 455 additions and 311 deletions.
17 changes: 10 additions & 7 deletions StevenVolckaert.EnterpriseLibrary.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{00269925-9ABB-475F-A63B-B57C55E26CD3}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -18,7 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{54EC9438-05E
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StevenVolckaert.Core", "src\StevenVolckaert.Core\StevenVolckaert.Core.csproj", "{9493EB60-BD91-426A-BDF1-4390456046E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StevenVolckaert.Core.Tests", "test\StevenVolckaert.Core.Tests\StevenVolckaert.Core.Tests.csproj", "{B2222404-4375-458C-9F04-C5F1D279CBA6}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StevenVolckaert.Core.Tests", "test\StevenVolckaert.Core.Tests\StevenVolckaert.Core.Tests.csproj", "{F6EAF516-F648-48C8-93EE-EC532AD996CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -30,16 +30,19 @@ Global
{9493EB60-BD91-426A-BDF1-4390456046E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9493EB60-BD91-426A-BDF1-4390456046E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9493EB60-BD91-426A-BDF1-4390456046E1}.Release|Any CPU.Build.0 = Release|Any CPU
{B2222404-4375-458C-9F04-C5F1D279CBA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2222404-4375-458C-9F04-C5F1D279CBA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2222404-4375-458C-9F04-C5F1D279CBA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2222404-4375-458C-9F04-C5F1D279CBA6}.Release|Any CPU.Build.0 = Release|Any CPU
{F6EAF516-F648-48C8-93EE-EC532AD996CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6EAF516-F648-48C8-93EE-EC532AD996CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6EAF516-F648-48C8-93EE-EC532AD996CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6EAF516-F648-48C8-93EE-EC532AD996CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9493EB60-BD91-426A-BDF1-4390456046E1} = {54EC9438-05ED-4ACD-AEF6-B31B353069EA}
{B2222404-4375-458C-9F04-C5F1D279CBA6} = {887100A5-003F-4148-85D8-9D9C9E7E5125}
{F6EAF516-F648-48C8-93EE-EC532AD996CA} = {887100A5-003F-4148-85D8-9D9C9E7E5125}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C23D0273-EEBA-4B5A-8DBE-8C742A67738E}
EndGlobalSection
EndGlobal
18 changes: 17 additions & 1 deletion src/StevenVolckaert.Core/IEnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static IEnumerable<T> Prepend<T>(this IEnumerable<T> source, T element)
/// Determines whether a sequence contains no elements.
/// </summary>
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
/// <param name="source">The <see cref="IEnumerable{T}"/> instance to check for emptiness. </param>
/// <param name="source">The <see cref="IEnumerable{T}"/> instance to check for emptiness.</param>
/// <returns>
/// <c>true</c> if the source sequence contains no elements; otherwise, <c>false</c>.
/// </returns>
Expand All @@ -82,6 +82,22 @@ public static bool IsEmpty<TSource>(this IEnumerable<TSource> source)
return !source.Any();
}

/// <summary>
/// Determines whether a sequence is <c>null</c> or contains no elements.
/// </summary>
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
/// <param name="source">
/// The <see cref="IEnumerable{T}"/> instance to check for <c>null</c> and emptiness.
/// </param>
/// <returns>
/// <c>true</c> if the source sequence is <c>null</c> or contains no elements;
/// otherwise, <c>false</c>.
/// </returns>
public static bool IsNullOrEmpty<TSource>(this IEnumerable<TSource> source)
{
return source.IsNull() || source.IsEmpty();
}

/// <summary>
/// Determines whether none of the elements of a sequence satisfies a condition.
/// </summary>
Expand Down
35 changes: 33 additions & 2 deletions src/StevenVolckaert.Core/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ public static class ObjectExtensions
/// <summary>
/// Casts the object as a <see cref="List{T}"/> of the specified type.
/// </summary>
/// <typeparam name="TResult">The type to cast the elements of <paramref name="source"/> to.</typeparam>
/// <typeparam name="TResult">
/// The type to cast the elements of <paramref name="source"/> to.
/// </typeparam>
/// <param name="source">
/// The <see cref="object"/> that needs to be casted to a <see cref="List{T}"/> of the specified type.
/// The <see cref="object"/> that needs to be casted to a <see cref="List{T}"/> of the specified
/// type.
/// </param>
/// <returns>
/// A <see cref="List{T}"/> that contains each element of the <paramref name="source"/>
Expand All @@ -40,5 +43,33 @@ public static List<TResult> AsList<TResult>(this object source)
? ((List<object>)source).Cast<TResult>().ToList()
: result;
}

/// <summary>
/// Returns a value that indicates whether the object is <c>null</c>.
/// </summary>
/// <param name="value">
/// The <see cref="object"/> instance this extension method affects.
/// </param>
/// <returns>
/// <c>true</c> if <paramref name="value"/> is <c>null</c>; otherwise, <c>false</c>.
/// </returns>
public static bool IsNull(this object value)
{
return null == value;
}

/// <summary>
/// Returns a value that indicates whether the object is not <c>null</c>.
/// </summary>
/// <param name="value">
/// The <see cref="object"/> instance this extension method affects.
/// </param>
/// <returns>
/// <c>true</c> if <paramref name="value"/> is not <c>null</c>; otherwise, <c>false</c>.
/// </returns>
public static bool IsNotNull(this object value)
{
return null != value;
}
}
}
4 changes: 1 addition & 3 deletions src/StevenVolckaert.Core/StevenVolckaert.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ See https://github.com/stevenvolckaert/enterprise-library for more information.<
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace>StevenVolckaert</RootNamespace>
<AssemblyVersion>1.1.1.0</AssemblyVersion>
<FileVersion>1.1.1.0</FileVersion>
<Version>1.1.1</Version>
<Version>1.2.0</Version>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net35' ">
Expand Down
27 changes: 26 additions & 1 deletion src/StevenVolckaert.Core/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,31 @@ public static TEnum ParseAs<TEnum>(this string value, bool ignoreCase)
return (TEnum)Enum.Parse(typeof(TEnum), value, ignoreCase);
}

/// <summary>
/// Converts the string to a specified enumeration, or returns the enumeration's default value
/// if the conversion fails.
/// </summary>
/// <typeparam name="TEnum">The type of <see cref="Enum"/> to parse as.</typeparam>
/// <param name="value">The <see cref="string"/> value.</param>
public static TEnum TryParseAs<TEnum>(this string value)
where TEnum : struct
{
return value.TryParseAs<TEnum>(ignoreCase: false);
}

/// <summary>
/// Converts the string to a specified enumeration, or returns the enumeration's default value
/// if the conversion fails. A value specifies whether the operation is case-insensitive.
/// </summary>
/// <typeparam name="TEnum">The type of <see cref="Enum"/> to parse as.</typeparam>
/// <param name="value">The <see cref="string"/> value.</param>
/// <param name="ignoreCase"><c>true</c> to ignore case; <c>false</c> to regard case.</param>
public static TEnum TryParseAs<TEnum>(this string value, bool ignoreCase)
where TEnum : struct
{
return value.TryParseAs<TEnum>(defaultResult: default(TEnum), ignoreCase: ignoreCase);
}

/// <summary>
/// Converts the string to a specified enumeration, or returns a specified default result if
/// the conversion fails.
Expand All @@ -390,7 +415,7 @@ public static TEnum TryParseAs<TEnum>(this string value, TEnum defaultResult)

/// <summary>
/// Converts the string to a specified enumeration, or returns a specified default result if
/// the conversion fails. A value specified whether the operation is case-insensitive.
/// the conversion fails. A value specifies whether the operation is case-insensitive.
/// </summary>
/// <typeparam name="TEnum">The type of <see cref="Enum"/> to parse as.</typeparam>
/// <param name="value">The <see cref="string"/> value.</param>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,56 @@
namespace StevenVolckaert.Globalization.Tests
{
using Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;

[TestClass]
public class CultureManagerTests
{
/* TODO Implement the unit tests. For instance: Calling any of the SetCulture methods should return
* the name of the culture after execution, which must equal the CurrentCultureName property of the
* culture manager (after execution). Steven Volckaert. December 13, 2016.
*/

//[TestMethod]
public void CultureManagerTest()
{
Assert.Fail();
}
//[Fact]
//public void CultureManagerTest()
//{
//}

//[TestMethod]
public void CultureManagerTest1()
{
Assert.Fail();
}
//[Fact]
//public void CultureManagerTest1()
//{
//}

//[TestMethod]
public void GetCultureInfoTest()
{
Assert.Fail();
}
//[Fact]
//public void GetCultureInfoTest()
//{
//}

//[TestMethod]
public void GetNeutralCultureNameTest()
{
Assert.Fail();
}
//[Fact]
//public void GetNeutralCultureNameTest()
//{
//}

//[TestMethod]
public void IsCultureSupportedTest()
{
Assert.Fail();
}
//[Fact]
//public void IsCultureSupportedTest()
//{
//}

//[TestMethod]
public void IsSpecificCultureSupportedTest()
{
Assert.Fail();
}
//[Fact]
//public void IsSpecificCultureSupportedTest()
//{
//}

//[TestMethod]
public void IsCultureSelectedTest()
{
Assert.Fail();
}
//[Fact]
//public void IsCultureSelectedTest()
//{
//}

//[TestMethod]
public void SetCultureTest1()
{
Assert.Fail();
}
//[Fact]
//public void SetCultureTest1()
//{
//}

[TestMethod]
[Fact]
public void SetCultureTest2()
{
var cultureManager =
Expand All @@ -68,23 +59,21 @@ public void SetCultureTest2()
supportedCultureNames: new string[] { "en-US", "nl-BE" }
);

Assert.AreEqual("en-US", cultureManager.SetCulture("pt", "zh-Hans"));
Assert.AreEqual("nl-BE", cultureManager.SetCulture("pt", "zh-Hans", "nl-BE"));
Assert.Equal("en-US", cultureManager.SetCulture("pt", "zh-Hans"));
Assert.Equal("nl-BE", cultureManager.SetCulture("pt", "zh-Hans", "nl-BE"));

// TODO Add additional asserts.
// Steven Volckaert. December 13, 2016.
}

//[TestMethod]
public void SetDefaultCultureTest()
{
Assert.Fail();
}
//[Fact]
//public void SetDefaultCultureTest()
//{
//}

//[TestMethod]
public void SetSpecificCultureTest()
{
Assert.Fail();
}
//[Fact]
//public void SetSpecificCultureTest()
//{
//}
}
}
39 changes: 19 additions & 20 deletions test/StevenVolckaert.Core.Tests/ICollectionExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
namespace StevenVolckaert.Tests
{
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;

[TestClass]
public class ICollectionExtensionsTests
{
[TestMethod]
[Fact]
public void AddRangeTest()
{
var source = new List<string> { "foo", "bar", "baz" };
var other = new List<string> { "bar", "foo", "qux" };
var expected = new List<string> { "foo", "bar", "baz", "bar", "foo", "qux" };
var subject = new List<string> { "foo", "bar", "baz" };
var other = new string[] { "bar", "foo", "qux" };
var expected = new string[] { "foo", "bar", "baz", "bar", "foo", "qux" };

source.AddRange(other);
subject.AddRange(other);

CollectionAssert.AreEqual(expected, source);
Assert.Equal(expected, subject);
}

[TestMethod]
[Fact]
public void AddRangeIndistinctTest()
{
var source = new List<string> { "foo", "bar", "baz" };
var other = new List<string> { "bar", "foo", "qux" };
var expected = new List<string> { "foo", "bar", "baz", "bar", "foo", "qux" };
var subject = new List<string> { "foo", "bar", "baz" };
var other = new string[] { "bar", "foo", "qux" };
var expected = new string[] { "foo", "bar", "baz", "bar", "foo", "qux" };

source.AddRange(other, isDistinct: false);
subject.AddRange(other, isDistinct: false);

CollectionAssert.AreEqual(expected, source);
Assert.Equal(expected, subject);
}

[TestMethod]
[Fact]
public void AddRangeDistinctTest()
{
var source = new List<string> { "foo", "bar", "baz" };
var other = new List<string> { "bar", "foo", "qux" };
var expected = new List<string> { "foo", "bar", "baz", "qux" };
var subject = new List<string> { "foo", "bar", "baz" };
var other = new string[] { "bar", "foo", "qux" };
var expected = new string[] { "foo", "bar", "baz", "qux" };

source.AddRange(other, isDistinct: true);
subject.AddRange(other, isDistinct: true);

CollectionAssert.AreEqual(expected, source);
Assert.Equal(expected, subject);
}
}
}
Loading

0 comments on commit d093570

Please sign in to comment.