From 429624abb508287807924e4328f4d616334f7243 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Sat, 14 Jan 2017 16:04:32 +0100 Subject: [PATCH 01/11] Adding unit tests for the extension methods on IEnumerable instances. --- .../IEnumerableExtensionsTests.cs | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs diff --git a/test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs b/test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs new file mode 100644 index 0000000..596aa04 --- /dev/null +++ b/test/StevenVolckaert.Core.Tests/IEnumerableExtensionsTests.cs @@ -0,0 +1,161 @@ +namespace StevenVolckaert.Tests +{ + using System; + using System.Linq; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class IEnumerableExtensionsTests + { + [TestMethod] + public void ExceptTest() + { + var source = new string[] { "foo", "bar", "baz" }; + + var actual = source.Except("xxx"); + Assert.IsTrue(actual.Count() == 3); + Assert.IsFalse(actual.Contains("xxx")); + + foreach (var item in source) + { + actual = source.Except(item); + Assert.IsTrue(actual.Count() == 2); + Assert.IsFalse(actual.Contains(item)); + } + } + + [TestMethod] + public void IsSubsetOf_ReturnsTrue() + { + var source = new string[] { "foo", "bar", "baz" }; + var other = new string[] { "x", "baz", "1", "bar", "foo", "y", "something", "z", "else" }; + Assert.IsTrue(source.IsSubsetOf(other)); + } + + [TestMethod] + public void IsSubsetOf_ReturnsFalse() + { + var source = new string[] { "foo", "bar", "baz" }; + var other = new string[] { "x", "bax", "1", "bar", "foo", "y", "something", "z", "else" }; + Assert.IsFalse(source.IsSubsetOf(other)); + } + + [TestMethod, ExpectedException(typeof(ArgumentNullException))] + public void OrderByOrdinal_ThrowsImmediatelyWhenArgumentIsNull() + { + string[] source = null; + source.OrderByOrdinal(x => x); + } + + [TestMethod, ExpectedException(typeof(ArgumentNullException))] + public void OrderByOrdinal_ThrowsImmediatelyWhenKeySelectorIsNull() + { + var source = new string[] { "foo 11", "baz 11", "foo", "bar", "baz", "foo 1", "bar 20", "foo 10", "bar 1", "baz 2" }; + source.OrderByOrdinal(null); + } + + [TestMethod] + public void OrderByOrdinalTest() + { + var source = new string[] { "foo 11", "baz 11", "foo", "bar", "baz", "foo 1", "bar 20", "foo 10", "bar 1", "baz 2" }; + var expected = new string[] { "bar", "bar 1", "bar 20", "baz", "baz 2", "baz 11", "foo", "foo 1", "foo 10", "foo 11" }; + var actual = source.OrderByOrdinal(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + + source = new string[] { "1", "10", "100", "101", "102", "11", "12", "13", "14", "15", "16", "17", "18", "19", "2", "20", "3", "4", "5", "6", "7", "8", "9" }; + expected = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "100", "101", "102" }; + actual = source.OrderByOrdinal(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + + source = new string[] { "File 1.txt", "File 10.txt", "File 11.csv", "File 2.jpg", "File 20.xls", "File 21.ppt", "File 3.doc" }; + expected = new string[] { "File 1.txt", "File 2.jpg", "File 3.doc", "File 10.txt", "File 11.csv", "File 20.xls", "File 21.ppt" }; + actual = source.OrderByOrdinal(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + + // Verify case-sensitive ordering. + source = new string[] { "File 1.txt", "file 10.txt", "File 11.csv", "file 2.jpg", "File 20.xls", "File 21.ppt", "File 3.doc" }; + expected = new string[] { "file 2.jpg", "file 10.txt", "File 1.txt", "File 3.doc", "File 11.csv", "File 20.xls", "File 21.ppt" }; + actual = source.OrderByOrdinal(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + } + + [TestMethod] + public void OrderByOrdinalCaseInsensitiveTest() + { + var source = new string[] { "File 1.txt", "file 10.txt", "File 11.csv", "file 2.jpg", "file 20.xls", "File 21.ppt", "File 3.doc" }; + var expected = new string[] { "File 1.txt", "file 2.jpg", "File 3.doc", "file 10.txt", "File 11.csv", "file 20.xls", "File 21.ppt" }; + var actual = source.OrderByOrdinal(x => x, ignoreCase: true).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + } + + [TestMethod] + public void OrderByOrdinalDescendingTest() + { + var source = new string[] { "foo 11", "baz 11", "foo", "bar", "baz", "foo 1", "bar 20", "foo 10", "bar 1", "baz 2" }; + var expected = new string[] { "foo 11", "foo 10", "foo 1", "foo", "baz 11", "baz 2", "baz", "bar 20", "bar 1", "bar" }; + var actual = source.OrderByOrdinalDescending(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + + source = new string[] { "1", "10", "100", "101", "102", "11", "12", "13", "14", "15", "16", "17", "18", "19", "2", "20", "3", "4", "5", "6", "7", "8", "9" }; + expected = new string[] { "102", "101", "100", "20", "19", "18", "17", "16", "15", "14", "13", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3", "2", "1" }; + actual = source.OrderByOrdinalDescending(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + + source = new string[] { "File 1.txt", "File 10.txt", "File 11.csv", "File 2.jpg", "File 20.xls", "File 21.ppt", "File 3.doc" }; + expected = new string[] { "File 21.ppt", "File 20.xls", "File 11.csv", "File 10.txt", "File 3.doc", "File 2.jpg", "File 1.txt" }; + actual = source.OrderByOrdinalDescending(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + + // Verify case-sensitive ordering. + source = new string[] { "File 1.txt", "file 10.txt", "File 11.csv", "file 2.jpg", "File 20.xls", "File 21.ppt", "File 3.doc" }; + expected = new string[] { "File 21.ppt", "File 20.xls", "File 11.csv", "File 3.doc", "File 1.txt", "file 10.txt", "file 2.jpg" }; + actual = source.OrderByOrdinalDescending(x => x).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + } + + [TestMethod] + public void OrderByOrdinalDescendingCaseInsensitiveTest() + { + var source = new string[] { "File 1.txt", "file 10.txt", "File 11.csv", "file 2.jpg", "file 20.xls", "File 21.ppt", "File 3.doc" }; + var expected = new string[] { "File 21.ppt", "file 20.xls", "File 11.csv", "file 10.txt", "File 3.doc", "file 2.jpg", "File 1.txt" }; + var actual = source.OrderByOrdinalDescending(x => x, ignoreCase: true).ToArray(); + + CollectionAssert.AreEqual(expected, actual); + } + + [TestMethod, ExpectedException(typeof(ArgumentNullException))] + public void ToObservableCollectionTest_ThrowsImmediatelyWhenArgumentIsNull() + { + string[] source = null; + var collection = source.ToObservableCollection(); + } + + [TestMethod] + public void ToStringTest() + { + var source = new string[] { "File 1.txt", "file 10.txt", "File 11.csv" }; + var expected = "File 1.txt; file 10.txt; File 11.csv"; + var actual = source.ToString(separator: "; "); + + Assert.AreEqual(expected, actual); + } + + [TestMethod] + public void UnionTest() + { + var source = new string[] { "foo", "bar" }; + var actual = source.Union("foo").Union("baz"); + Assert.IsTrue(actual.Count() == 3); + Assert.IsTrue(actual.Contains("baz")); + } + } +} From 083b601afd08e1ee14fd0a917d6ffb1ec70abc8e Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Sat, 14 Jan 2017 16:08:26 +0100 Subject: [PATCH 02/11] Adding unit tests for the extension methods on System.String values. --- .../StringExtensionsTests.cs | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs diff --git a/test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs b/test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs new file mode 100644 index 0000000..f09eeda --- /dev/null +++ b/test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs @@ -0,0 +1,76 @@ +namespace StevenVolckaert.Tests +{ + using System; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class StringExtensionsTests + { + public enum MockedEnumeration + { + Foo, + Bar + } + + [TestMethod] + public void ParseAs_Succeeds() + { + Assert.AreEqual(MockedEnumeration.Foo, "Foo".ParseAs()); + Assert.AreEqual(MockedEnumeration.Bar, "Bar".ParseAs()); + } + + [TestMethod, ExpectedException(typeof(ArgumentException))] + public void ParseAs_ThrowsArgumentException() + { + // "Baz" is not en enumeration value of MockedEnumeration. + "Baz".ParseAs(); + } + + [TestMethod, ExpectedException(typeof(ArgumentNullException))] + public void ParseAs_ThrowsArgumentNullException() + { + string str = null; + str.ParseAs(); + } + + [TestMethod] + public void ParseAsWhileIgnoringCase_Succeeds() + { + Assert.AreEqual(MockedEnumeration.Foo, "foo".ParseAs(ignoreCase: true)); + Assert.AreEqual(MockedEnumeration.Bar, "bar".ParseAs(ignoreCase: true)); + } + + [TestMethod, ExpectedException(typeof(ArgumentException))] + public void ParseAsWhileIgnoringCase_ThrowsArgumentException() + { + "baz".ParseAs(ignoreCase: true); + } + + [TestMethod] + public void TryParseAs_Succeeds() + { + Assert.AreEqual(MockedEnumeration.Foo, "Foo".TryParseAs(MockedEnumeration.Foo)); + Assert.AreEqual(MockedEnumeration.Bar, "Bar".TryParseAs(MockedEnumeration.Foo)); + Assert.AreEqual(MockedEnumeration.Foo, "Baz".TryParseAs(MockedEnumeration.Foo)); + + string str = null; + Assert.AreEqual(MockedEnumeration.Bar, str.TryParseAs(MockedEnumeration.Bar)); + } + + [TestMethod] + public void TryParseAsWhileIgnoringCase_Succeeds() + { + Assert.AreEqual(MockedEnumeration.Foo, "foo".TryParseAs(MockedEnumeration.Foo, ignoreCase: true)); + Assert.AreEqual(MockedEnumeration.Bar, "bar".TryParseAs(MockedEnumeration.Foo, ignoreCase: true)); + Assert.AreEqual(MockedEnumeration.Foo, "baz".TryParseAs(MockedEnumeration.Foo, ignoreCase: true)); + } + + [TestMethod] + public void TryTrimTest() + { + Assert.AreEqual("Foo", " Foo ".TryTrim()); + Assert.AreEqual("Bar", "Bar".TryTrim()); + Assert.AreEqual(null, ((String)null).TryTrim()); + } + } +} From cbec1427c64d1f107d8419fec4599b86fed84913 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Mon, 16 Jan 2017 12:35:44 +0100 Subject: [PATCH 03/11] Adding StevenVolckaert.Hyperlink structure. --- src/StevenVolckaert.Core/Hyperlink.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/StevenVolckaert.Core/Hyperlink.cs diff --git a/src/StevenVolckaert.Core/Hyperlink.cs b/src/StevenVolckaert.Core/Hyperlink.cs new file mode 100644 index 0000000..1399b73 --- /dev/null +++ b/src/StevenVolckaert.Core/Hyperlink.cs @@ -0,0 +1,19 @@ +namespace StevenVolckaert +{ + using System; + + /// + /// Represents a hyperlink. + /// + public struct Hyperlink + { + /// + /// Gets or sets the label of the hyperlink. + /// + public string Label { get; set; } + /// + /// Gets or sets the URI of the hyperlink. + /// + public Uri Uri { get; set; } + } +} From 99a2f30040afc58ad0799bb45c848705f8dd0786 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Wed, 18 Jan 2017 08:48:58 +0100 Subject: [PATCH 04/11] Adding static method CountryCodes.IsBeneluxUnionMemberState(string). --- src/StevenVolckaert.Core/CountryCodes.cs | 25 +++++++++++++++++++ .../RegexValidationPatterns.cs | 20 +++++++++------ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/StevenVolckaert.Core/CountryCodes.cs b/src/StevenVolckaert.Core/CountryCodes.cs index 3c23ed8..b2f136c 100644 --- a/src/StevenVolckaert.Core/CountryCodes.cs +++ b/src/StevenVolckaert.Core/CountryCodes.cs @@ -1,6 +1,8 @@ namespace StevenVolckaert { + using System; using System.Collections.Generic; + using System.Text.RegularExpressions; #if !NET35 using System.Collections.ObjectModel; #endif @@ -190,5 +192,28 @@ public static class CountryCodes //Republic of Code used for North Yemen before 1990 YT Mayotte 1993 .yt ISO 3166-2:YT ZA South Africa //1974 .za ISO 3166-2:ZA Code taken from name in Dutch: Zuid-Afrika ZM Zambia 1974 .zm ISO 3166-2:ZM ZW //Zimbabwe + + private static readonly Regex _beneluxUnionMemberStateCountryCodeRegex = + new Regex(RegexValidationPatterns.BeneluxUnionMemberStateCountryCode, RegexOptions.IgnoreCase); + + /// + /// Returns a value that indicates whether the specified ISO 3166-1 alpha-2 country code represents + /// a member state of the Benelux Union. + /// + /// The ISO 3166-1 alpha-2 country code representing the country. + /// + /// true if represents a Benelux Union member state; + /// otherwise, false. + /// + /// + /// is null, empty, or white space. + /// + public static bool IsBeneluxUnionMemberState(string countryCode) + { + if (countryCode.IsNullOrWhiteSpace()) + throw new ArgumentException(Resources.ValueNullEmptyOrWhiteSpace, nameof(countryCode)); + + return _beneluxUnionMemberStateCountryCodeRegex.IsMatch(countryCode); + } } } diff --git a/src/StevenVolckaert.Core/RegexValidationPatterns.cs b/src/StevenVolckaert.Core/RegexValidationPatterns.cs index 9020499..584fc46 100644 --- a/src/StevenVolckaert.Core/RegexValidationPatterns.cs +++ b/src/StevenVolckaert.Core/RegexValidationPatterns.cs @@ -1,30 +1,36 @@ namespace StevenVolckaert { /// - /// Provides access to regular expression patterns that are used to validate strings. + /// Provides regular expression patterns that are used to validate strings. /// public static class RegexValidationPatterns { /// - /// A regular expression pattern used to validate strings that represent - /// a single ISO 3166-1 alpha-2 country code. + /// A regular expression pattern used to validate strings that represent + /// a single ISO 3166-1 alpha-2 country code. /// public const string CountryCode = @"^[A-Z]{2}$"; /// - /// A regular expression pattern used to validate strings that represent - /// a single culture name, as used by the class. + /// A regular expression pattern used to validate strings that represent + /// an ISO 3166-1 alpha-2 country code of a Benelux Union member state. + /// + public const string BeneluxUnionMemberStateCountryCode = @"BE|NL|LU"; + + /// + /// A regular expression pattern used to validate strings that represent + /// a single culture name, as used by the class. /// public const string CultureName = @"[a-z]{2}(-[A-Za-z]{2,8})?"; /// - /// A regular expression pattern used to validate strings that represent a single email address. + /// A regular expression pattern used to validate strings that represent a single email address. /// public const string EmailAddress = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; /// - /// A regular expression pattern used to validate strings that represent a 32-bit signed integer. + /// A regular expression pattern used to validate strings that represent a 32-bit signed integer. /// public const string Int32 = @"^(-)?[0-9]+$"; } From 184b6f9dbc455930aa89cc7ef248d2c85f11fdec Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Wed, 18 Jan 2017 11:29:05 +0100 Subject: [PATCH 05/11] Adding BrowsingContextName property. --- src/StevenVolckaert.Core/Hyperlink.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/StevenVolckaert.Core/Hyperlink.cs b/src/StevenVolckaert.Core/Hyperlink.cs index 1399b73..5883710 100644 --- a/src/StevenVolckaert.Core/Hyperlink.cs +++ b/src/StevenVolckaert.Core/Hyperlink.cs @@ -7,6 +7,13 @@ /// public struct Hyperlink { + /// + /// Gets or sets the browsing context name of the hyperlink. + /// + /// + /// See http://w3c.github.io/html/browsers.html#browsing-context-names for more information. + /// + public string BrowsingContextName { get; set; } /// /// Gets or sets the label of the hyperlink. /// From d631b2090dff0acbdff840812910a4bd142792a2 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Thu, 19 Jan 2017 12:16:26 +0100 Subject: [PATCH 06/11] Adding String.IsGuid() extension method. --- src/StevenVolckaert.Core/StringExtensions.cs | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/StevenVolckaert.Core/StringExtensions.cs b/src/StevenVolckaert.Core/StringExtensions.cs index cecd3c5..8edda45 100644 --- a/src/StevenVolckaert.Core/StringExtensions.cs +++ b/src/StevenVolckaert.Core/StringExtensions.cs @@ -124,6 +124,32 @@ public static bool IsDecimal(this string value) } } + /// + /// Returns a value that indicates whether the string represents a value. + /// + /// The value this extension method affects. + /// + /// true if represents a value; + /// otherwise, false. + /// + public static bool IsGuid(this string value) + { +#if NET35 + try + { + var guid = new Guid(value); + return true; + } + catch (Exception) + { + return false; + } +#else + Guid guid; + return Guid.TryParse(value, out guid); +#endif + } + /// /// Returns a value that indicates whether the string represents a 32-bit signed integer. /// From 70a4e7fde852c8a19cdf35608f6fe4835d6a9eef Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Mon, 27 Feb 2017 10:10:43 +0100 Subject: [PATCH 07/11] Adding extension methods Int32.BytesToString() and Int32.BytesToString(UnitOfInformationPrefix). --- src/StevenVolckaert.Core/Int32Extensions.cs | 30 ++++++++++++++++ src/StevenVolckaert.Core/Int64Extensions.cs | 34 +++++++------------ .../UnitOfInformationPrefix.cs | 21 ++++++++++++ 3 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 src/StevenVolckaert.Core/UnitOfInformationPrefix.cs diff --git a/src/StevenVolckaert.Core/Int32Extensions.cs b/src/StevenVolckaert.Core/Int32Extensions.cs index 413e59d..848fee0 100644 --- a/src/StevenVolckaert.Core/Int32Extensions.cs +++ b/src/StevenVolckaert.Core/Int32Extensions.cs @@ -1,5 +1,6 @@ namespace StevenVolckaert { + using System; using System.Globalization; /// @@ -25,6 +26,35 @@ public static bool IsOdd(this int value) return !value.IsEven(); } + /// + /// Returns a string that represents a number of bytes in a human-readable format, + /// using the prefix. + /// + /// The value, in bytes. + /// + /// A human-readable string representation of , using powers of 1024. + /// + public static string BytesToString(this int value) + { + return ((ulong)value).BytesToString(); + } + + /// + /// Returns a string that represent the value in a human-readable format. + /// + /// The value, in bytes. + /// The prefix to be used in the string representation. + /// + /// has an illegal value. + /// + /// + /// A human-readable string representation of . + /// + public static string BytesToString(this int value, UnitOfInformationPrefix prefix) + { + return ((ulong)value).BytesToString(prefix); + } + /// /// Returns a string that represents the value in a human-readable format. /// diff --git a/src/StevenVolckaert.Core/Int64Extensions.cs b/src/StevenVolckaert.Core/Int64Extensions.cs index 075841c..d834857 100644 --- a/src/StevenVolckaert.Core/Int64Extensions.cs +++ b/src/StevenVolckaert.Core/Int64Extensions.cs @@ -4,27 +4,6 @@ using System.Globalization; using System.Linq; - /// - /// Specifies a prefix that is used in combination with a unit of information (e.g. byte). - /// - public enum UnitOfInformationPrefix - { - /// - /// No prefix, indicating a power of 1. - /// - None = 0, - - /// - /// A decimal prefix, indicating a power of 1000. - /// - Decimal = 1000, - - /// - /// A binary prefix, indicating a power of 1024. - /// - Binary = 1024 - } - /// /// Provides extension methods for and values. /// @@ -36,6 +15,19 @@ public static class Int64Extensions private static readonly string[] _decimalUnitSymbols = new string[] { "B", "kB", "MB", "GB", "TB", "PB" }; + /// + /// Returns a string that represents a number of bytes in a human-readable format, + /// using the prefix. + /// + /// The value, in bytes. + /// + /// A human-readable string representation of , using powers of 1024. + /// + public static string BytesToString(this ulong value) + { + return value.BytesToString(UnitOfInformationPrefix.Binary); + } + /// /// Returns a string that represents a number of bytes in a human-readable format. /// diff --git a/src/StevenVolckaert.Core/UnitOfInformationPrefix.cs b/src/StevenVolckaert.Core/UnitOfInformationPrefix.cs new file mode 100644 index 0000000..7d8508a --- /dev/null +++ b/src/StevenVolckaert.Core/UnitOfInformationPrefix.cs @@ -0,0 +1,21 @@ +namespace StevenVolckaert +{ + /// + /// Specifies a prefix that is used in combination with a unit of information (e.g. byte). + /// + public enum UnitOfInformationPrefix + { + /// + /// No prefix, indicating a power of 1. + /// + None = 0, + /// + /// A decimal prefix, indicating a power of 1000. + /// + Decimal = 1000, + /// + /// A binary prefix, indicating a power of 1024. + /// + Binary = 1024 + } +} From a0d574fa9dc851c5a3b532332d95801ee9ef7c41 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Mon, 27 Feb 2017 10:13:00 +0100 Subject: [PATCH 08/11] Moving class library projects into the 'src' solution directory, so the solution in Solution Explorer maps exactly to the directory structure on disk. --- StevenVolckaert.EnterpriseLibrary.sln | 3 +++ 1 file changed, 3 insertions(+) diff --git a/StevenVolckaert.EnterpriseLibrary.sln b/StevenVolckaert.EnterpriseLibrary.sln index 1e21108..9559677 100644 --- a/StevenVolckaert.EnterpriseLibrary.sln +++ b/StevenVolckaert.EnterpriseLibrary.sln @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{887100A5-0 EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StevenVolckaert.Core.Tests", "test\StevenVolckaert.Core.Tests\StevenVolckaert.Core.Tests.xproj", "{A97F5579-7D70-4FD4-8D6B-DC12E4909AD2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{54EC9438-05ED-4ACD-AEF6-B31B353069EA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,6 +40,7 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {3E5DE170-18C8-4B09-90A6-7D158A6C54C5} = {54EC9438-05ED-4ACD-AEF6-B31B353069EA} {A97F5579-7D70-4FD4-8D6B-DC12E4909AD2} = {887100A5-003F-4148-85D8-9D9C9E7E5125} EndGlobalSection EndGlobal From 7a2207d243058d5536ed70b1f5698754cb7efc8d Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Wed, 1 Mar 2017 20:54:42 +0100 Subject: [PATCH 09/11] Limiting maximum line length to 110 characters. --- .../Globalization/CultureManagerTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/StevenVolckaert.Core.Tests/Globalization/CultureManagerTests.cs b/test/StevenVolckaert.Core.Tests/Globalization/CultureManagerTests.cs index e53862c..05c77f7 100644 --- a/test/StevenVolckaert.Core.Tests/Globalization/CultureManagerTests.cs +++ b/test/StevenVolckaert.Core.Tests/Globalization/CultureManagerTests.cs @@ -6,9 +6,9 @@ [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. + /* 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] From 47533e56e828082cf9617c0d429209b484a4bd10 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Wed, 1 Mar 2017 20:55:54 +0100 Subject: [PATCH 10/11] Adding unit test IsGuidTest. --- .../StringExtensionsTests.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs b/test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs index f09eeda..e6ccec1 100644 --- a/test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs +++ b/test/StevenVolckaert.Core.Tests/StringExtensionsTests.cs @@ -1,11 +1,54 @@ namespace StevenVolckaert.Tests { using System; + using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class StringExtensionsTests { + [TestMethod] + public void IsGuidTest() + { + var validGuidStrings = new List + { + // Lower case, no dashes, no braces. + "dfdc04eb167941cd8e23ef66d6cc756e", + // Upper case, no dashes, no braces. + "DFDC04EB167941CD8E23EF66D6CC756E", + // lower case, with dashes, no braces. + "dfdc04eb-1679-41cd-8e23-ef66d6cc756e", + // Upper case, with dashes, no braces. + "DFDC04EB-1679-41CD-8E23-EF66D6CC756E", + // Lower case, with dashes, with braces. + "{dfdc04eb-1679-41cd-8e23-ef66d6cc756e}", + // Upper case, with dashes, with braces. + "{DFDC04EB-1679-41CD-8E23-EF66D6CC756E}", + }; + + validGuidStrings.ForEach( + x => Assert.IsTrue(x.IsGuid(), $"Expected string value '{x}' to be a valid GUID.") + ); + + var invalidGuidStrings = new List + { + // Contains invalid character ('g'). + "gfdc04eb167941cd8e23ef66d6cc756e", + // Not enough characters. + "FDC04EB167941CD8E23EF66D6CC756E", + // Not enough characters. + "{dfdc04eb167941cd8e23ef66d6cc756}", + // Dash in the wrong place. + "DFDC04EB-16794-1CD-8E23EF66D6CC756E", + // A random string. + "Hello world!", + }; + + invalidGuidStrings.ForEach( + x => Assert.IsFalse(x.IsGuid(), $"Expected string value '{x}' to be an invalid GUID.") + ); + } + public enum MockedEnumeration { Foo, From 12e3f97fe94e6b380ef277c5faee0a01d5d86b77 Mon Sep 17 00:00:00 2001 From: Steven Volckaert Date: Wed, 1 Mar 2017 21:00:28 +0100 Subject: [PATCH 11/11] Updating project versions to 1.0.0. --- appveyor.yml | 2 +- src/StevenVolckaert.Core/project.json | 2 +- test/StevenVolckaert.Core.Tests/project.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index aa9f1d3..26c76a1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.1.1-{build} +version: 1.0.0-{build} build: verbosity: minimal configuration: diff --git a/src/StevenVolckaert.Core/project.json b/src/StevenVolckaert.Core/project.json index 809ec93..5bcd835 100644 --- a/src/StevenVolckaert.Core/project.json +++ b/src/StevenVolckaert.Core/project.json @@ -3,7 +3,7 @@ "copyright": "Copyright (c) 2016 Steven Volckaert", "description": "Steven Volckaert's Enterprise Library contains reusable software components designed to assist software developers with writing less and semantically more meaningful code.\n\nSee https://github.com/stevenvolckaert/enterprise-library for more information.", "language": "en-US", - "version": "0.1.1-*", + "version": "1.0.0-*", "authors": [ "Steven Volckaert" ], "frameworks": { "net35": {}, diff --git a/test/StevenVolckaert.Core.Tests/project.json b/test/StevenVolckaert.Core.Tests/project.json index c293d2d..4882276 100644 --- a/test/StevenVolckaert.Core.Tests/project.json +++ b/test/StevenVolckaert.Core.Tests/project.json @@ -3,7 +3,7 @@ "copyright": "Copyright (c) 2016 Steven Volckaert", "description": "Unit test project for StevenVolckaert.Core.", "language": "en-US", - "version": "0.1.1-*", + "version": "1.0.0-*", "authors": [ "Steven Volckaert" ], "testRunner": "mstest",