From 0891a24b5bb3ff4d615e1985921ba938281c60e7 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 15 Jan 2025 16:31:45 +0000 Subject: [PATCH] Use Shouldly over FluentAssertions --- .../Arrays/ArrayExtensionsTests.cs | 56 +++---- .../Arrays/ByteArrayExtensionsTests.cs | 6 +- .../Assemblies/AssemblyExtensionsTests.cs | 12 +- .../StringComparisonEqualityComparerTests.cs | 10 +- .../Conversion/ConvertExtensionsTest.cs | 44 ++--- .../Conversion/GuidExtensionsTests.cs | 18 +-- .../DNX.Extensions.Tests.csproj | 2 +- .../DateTimes/DateTimeExtensionsTests.cs | 152 +++++++++--------- .../Dictionaries/DictionaryExtensionsTests.cs | 40 ++--- .../Enums/EnumExtensionsTests.cs | 6 +- .../Execution/RunSafelyTests.cs | 64 ++++---- .../IO/DirectoryInfoExtensionsTests.cs | 92 +++++------ .../IO/FileInfoExtensionsTests.cs | 12 +- .../Linq/EnumerableExtensionsTests.cs | 136 ++++++++-------- .../Reflection/ReflectionExtensionsTests.cs | 16 +- .../Strings/ArgumentParserExtensionsTests.cs | 10 +- .../Strings/BuiltInTypesExtensionsTests.cs | 12 +- .../Strings/StringExtensionsTests.cs | 136 ++++++++-------- 18 files changed, 413 insertions(+), 411 deletions(-) diff --git a/tests/DNX.Extensions.Tests/Arrays/ArrayExtensionsTests.cs b/tests/DNX.Extensions.Tests/Arrays/ArrayExtensionsTests.cs index 0b22580..e5269ea 100644 --- a/tests/DNX.Extensions.Tests/Arrays/ArrayExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Arrays/ArrayExtensionsTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Arrays; -using FluentAssertions; +using Shouldly; using Xunit; using Xunit.Abstractions; @@ -21,7 +21,7 @@ public void Test_IsNullOrEmpty(string byteArray, bool isEmpty) .Select(x => Convert.ToByte(x)) .ToArray(); - bytes.IsNullOrEmpty().Should().Be(isEmpty); + bytes.IsNullOrEmpty().ShouldBe(isEmpty); } [Fact] @@ -31,13 +31,13 @@ public void Test_PadLeft_when_greater_than_existing_array_length() var result = values.PadLeft(8); - values.Length.Should().Be(6); - result.Length.Should().Be(8); + values.Length.ShouldBe(6); + result.Length.ShouldBe(8); for (var i = 1; i <= result.Length; ++i) { outputHelper.WriteLine($"Index: {i}"); - result[^i].Should().Be(i > values.Length ? default : values[^i]); + result[^i].ShouldBe(i > values.Length ? default : values[^i]); } } @@ -50,13 +50,13 @@ public void Test_PadLeft_when_less_than_existing_array_length() var result = values.PadLeft(4); // Assert - values.Length.Should().Be(6); - result.Length.Should().Be(4); + values.Length.ShouldBe(6); + result.Length.ShouldBe(4); for (var i = 1; i <= result.Length; ++i) { outputHelper.WriteLine($"Index: {i}"); - result[^i].Should().Be(values[^i]); + result[^i].ShouldBe(values[^i]); } } @@ -72,8 +72,8 @@ public void Test_ShiftLeft_defaults_populated_array() var result = values.ShiftLeft(); // Assert - result.Length.Should().Be(values.Length); - result.Should().BeEquivalentTo(expected); + result.Length.ShouldBe(values.Length); + result.ShouldBeEquivalentTo(expected); } [Fact] @@ -86,8 +86,8 @@ public void Test_ShiftLeft_by_number_populated_array() var result = values.ShiftLeft(by: 3); // Assert - result.Length.Should().Be(values.Length); - result.Should().BeEquivalentTo(expected); + result.Length.ShouldBe(values.Length); + result.ShouldBeEquivalentTo(expected); } [Fact] @@ -100,8 +100,8 @@ public void Test_ShiftLeft_with_fill_value_populated_array() var result = values.ShiftLeft(by: 2, fillValue: "0"); // Assert - result.Length.Should().Be(values.Length); - result.Should().BeEquivalentTo(expected); + result.Length.ShouldBe(values.Length); + result.ShouldBeEquivalentTo(expected); } [Fact] @@ -111,8 +111,8 @@ public void Test_ShiftLeft_null_array() var result = values.ShiftLeft(); - result.Should().NotBeNull(); - result.Length.Should().Be(0); + result.ShouldNotBeNull(); + result.Length.ShouldBe(0); } } @@ -128,8 +128,8 @@ public void Test_ShiftRight_defaults_populated_array() var result = values.ShiftRight(); // Assert - result.Length.Should().Be(values.Length); - result.Should().BeEquivalentTo(expected); + result.Length.ShouldBe(values.Length); + result.ShouldBeEquivalentTo(expected); } [Fact] @@ -142,8 +142,8 @@ public void Test_ShiftRight_by_number_populated_array() var result = values.ShiftRight(by: 3); // Assert - result.Length.Should().Be(values.Length); - result.Should().BeEquivalentTo(expected); + result.Length.ShouldBe(values.Length); + result.ShouldBeEquivalentTo(expected); } [Fact] @@ -156,8 +156,8 @@ public void Test_ShiftRight_with_fill_value_populated_array() var result = values.ShiftRight(by: 2, fillValue: "0"); // Assert - result.Length.Should().Be(values.Length); - result.Should().BeEquivalentTo(expected); + result.Length.ShouldBe(values.Length); + result.ShouldBeEquivalentTo(expected); } [Fact] @@ -167,8 +167,8 @@ public void Test_ShiftRight_null_array() var result = values.ShiftRight(); - result.Should().NotBeNull(); - result.Length.Should().Be(0); + result.ShouldNotBeNull(); + result.Length.ShouldBe(0); } } @@ -182,8 +182,8 @@ public void Reduce_can_produce_an_appropriate_output_for_bytes(byte[] input, int var result = input.Reduce(targetSize, method); // Assert - result.Length.Should().BeLessThanOrEqualTo(targetSize); - result.Should().BeEquivalentTo(expectedResult); + result.Length.ShouldBeLessThanOrEqualTo(targetSize); + result.ShouldBeEquivalentTo(expectedResult); } [Theory] @@ -194,8 +194,8 @@ public void Reduce_can_produce_an_appropriate_output_for_strings(string[] input, var result = input.Reduce(targetSize, method); // Assert - result.Length.Should().BeLessThanOrEqualTo(targetSize); - result.Should().BeEquivalentTo(expectedResult); + result.Length.ShouldBeLessThanOrEqualTo(targetSize); + result.ShouldBeEquivalentTo(expectedResult); } // Useful : https://www.compscilib.com/calculate/binaryxor?variation=default diff --git a/tests/DNX.Extensions.Tests/Arrays/ByteArrayExtensionsTests.cs b/tests/DNX.Extensions.Tests/Arrays/ByteArrayExtensionsTests.cs index aee1a24..7e5a3fb 100644 --- a/tests/DNX.Extensions.Tests/Arrays/ByteArrayExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Arrays/ByteArrayExtensionsTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Arrays; -using FluentAssertions; +using Shouldly; using Xunit; namespace DNX.Extensions.Tests.Arrays; @@ -19,7 +19,7 @@ public void Test_GetAsciiString(string byteText, string expectedResult) var result = bytes.GetAsciiString(); - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -34,6 +34,6 @@ public void Test_ToHexString(string byteText, string expectedResult) var result = bytes.ToHexString(); - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } diff --git a/tests/DNX.Extensions.Tests/Assemblies/AssemblyExtensionsTests.cs b/tests/DNX.Extensions.Tests/Assemblies/AssemblyExtensionsTests.cs index 22c18fa..95d134c 100644 --- a/tests/DNX.Extensions.Tests/Assemblies/AssemblyExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Assemblies/AssemblyExtensionsTests.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Resources; using DNX.Extensions.Assemblies; -using FluentAssertions; +using Shouldly; using Xunit; using Xunit.Abstractions; @@ -21,7 +21,7 @@ public void GetEmbeddedResourceText_can_read_resource_successfully() testOutputHelper.WriteLine("Result: {0}", result); // Assert - result.Should().NotBeNull(); + result.ShouldNotBeNull(); } [Fact] @@ -38,8 +38,8 @@ public void GetEmbeddedResourceText_throws_on_unknown_resource_name() testOutputHelper.WriteLine("Exception Message: {0}", ex?.Message); // Assert - ex.Should().NotBeNull(); - ex.Message.Should().Contain(name); + ex.ShouldNotBeNull(); + ex.Message.ShouldContain(name); } [Fact] @@ -55,6 +55,6 @@ public void GetEmbeddedResourceText_can_read_resource_with_specific_namespace_su testOutputHelper.WriteLine("Result: {0}", result); // Assert - result.Should().NotBeNull(); + result.ShouldNotBeNull(); } -} \ No newline at end of file +} diff --git a/tests/DNX.Extensions.Tests/Comparers/StringComparisonEqualityComparerTests.cs b/tests/DNX.Extensions.Tests/Comparers/StringComparisonEqualityComparerTests.cs index d4724a9..d11b9b7 100644 --- a/tests/DNX.Extensions.Tests/Comparers/StringComparisonEqualityComparerTests.cs +++ b/tests/DNX.Extensions.Tests/Comparers/StringComparisonEqualityComparerTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Comparers; -using FluentAssertions; +using Shouldly; using Xunit; namespace DNX.Extensions.Tests.Comparers; @@ -14,7 +14,7 @@ public void DefaultConstructor_works_as_expected() { var sut = new StringComparisonEqualityComparer(); - sut.StringComparisonMethod.Should().Be(StringComparison.CurrentCulture); + sut.StringComparisonMethod.ShouldBe(StringComparison.CurrentCulture); } [Theory] @@ -23,7 +23,7 @@ public void Constructor_for_StringComparison_works_as_expected(StringComparison { var sut = new StringComparisonEqualityComparer(stringComparison); - sut.StringComparisonMethod.Should().Be(stringComparison); + sut.StringComparisonMethod.ShouldBe(stringComparison); } [Theory] @@ -37,7 +37,7 @@ public void Equals_compares_as_expected(string x, string y, StringComparison str var result = Sut.Equals(x, y); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -52,7 +52,7 @@ public void GetHashCode_compares_as_expected(string x, string y, StringCompariso var resultY = Sut.GetHashCode(y); // Assert - (resultX == resultY).Should().Be(expectedResult); + (resultX == resultY).ShouldBe(expectedResult); } #region TestData diff --git a/tests/DNX.Extensions.Tests/Conversion/ConvertExtensionsTest.cs b/tests/DNX.Extensions.Tests/Conversion/ConvertExtensionsTest.cs index 4f5cbbf..a36b706 100644 --- a/tests/DNX.Extensions.Tests/Conversion/ConvertExtensionsTest.cs +++ b/tests/DNX.Extensions.Tests/Conversion/ConvertExtensionsTest.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Conversion; -using FluentAssertions; +using Shouldly; using Xunit; namespace DNX.Extensions.Tests.Conversion; @@ -31,7 +31,7 @@ public void ToStringOrDefault_without_override_can_convert_successfully(object i { var result = instance.ToStringOrDefault(); - result.Should().Be(expected); + result.ShouldBe(expected); } [Theory] @@ -43,7 +43,7 @@ public void ToStringOrDefault_with_override_can_convert_successfully(object inst { var result = instance.ToStringOrDefault(defaultValue); - result.Should().Be(expected); + result.ShouldBe(expected); } } @@ -61,7 +61,7 @@ public void ToBoolean_without_override_can_convert_successfully(string text, boo { var result = text.ToBoolean(); - result.Should().Be(expected); + result.ShouldBe(expected); } [Theory] @@ -77,7 +77,7 @@ public void ToBoolean_with_override_can_convert_successfully(string text, bool d { var result = text.ToBoolean(defaultValue); - result.Should().Be(expected); + result.ShouldBe(expected); } } @@ -94,7 +94,7 @@ public void ToInt32_without_override_can_convert_successfully(string text, int e { var result = text.ToInt32(); - result.Should().Be(expected); + result.ShouldBe(expected); } [Theory] @@ -109,7 +109,7 @@ public void ToInt32_with_override_can_convert_successfully(string text, int defa { var result = text.ToInt32(defaultValue); - result.Should().Be(expected); + result.ShouldBe(expected); } } @@ -124,7 +124,7 @@ public void ToEnum_without_override_can_convert_Numbers_enum_successfully(string { var result = text.ToEnum(); - result.Should().Be(expected); + result.ShouldBe(expected); ; } @@ -137,7 +137,7 @@ public void ToEnum_with_override_can_convert_Numbers_enum_successfully(string te { var result = text.ToEnum(defaultValue); - result.Should().Be(expected); + result.ShouldBe(expected); ; } } @@ -152,7 +152,7 @@ public void ToGuid_without_default_can_convert_successfully(string text, string { var result = text.ToGuid(); - result.ToString().Should().BeEquivalentTo(expected); + result.ToString().ShouldBe(expected, StringCompareShould.IgnoreCase); } [Theory] @@ -164,7 +164,7 @@ public void ToGuid_with_default_can_convert_successfully(string text, string def { var result = text.ToGuid(Guid.Parse(defaultValue)); - result.ToString().Should().BeEquivalentTo(expected); + result.ToString().ShouldBe(expected, StringCompareShould.IgnoreCase); } } @@ -175,7 +175,7 @@ public void To_without_default_for_null_class_instance_can_convert_object_succes { var instance = (TestClass2)null; var result = instance.To(); - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -183,8 +183,8 @@ public void To_without_default_for_related_class_can_convert_object_successfully { var instance = new TestClass2(); var result = instance.To(); - result.Should().NotBeNull(); - result.Should().Be(instance); + result.ShouldNotBeNull(); + result.ShouldBe(instance); } [Fact] @@ -192,7 +192,7 @@ public void To_without_default_for_unrelated_class_can_convert_object_successful { var instance = new TestClass3(); var result = instance.To(); - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -201,8 +201,8 @@ public void To_with_default_for_null_class_instance_can_convert_object_successfu var instance = (TestClass2)null; var defaultValue = new TestClass1(); var result = instance.To(defaultValue); - result.Should().NotBeNull(); - result.Should().Be(defaultValue); + result.ShouldNotBeNull(); + result.ShouldBe(defaultValue); } [Fact] @@ -211,8 +211,8 @@ public void To_with_default_for_related_class_can_convert_object_successfully() var defaultValue = new TestClass1(); var instance = new TestClass2(); var result = instance.To(defaultValue); - result.Should().NotBeNull(); - result.Should().Be(instance); + result.ShouldNotBeNull(); + result.ShouldBe(instance); } [Fact] @@ -221,8 +221,8 @@ public void To_with_default_for_unrelated_class_can_convert_object_successfully( var defaultValue = new TestClass1(); var instance = new TestClass3(); var result = instance.To(defaultValue); - result.Should().NotBeNull(); - result.Should().Be(defaultValue); + result.ShouldNotBeNull(); + result.ShouldBe(defaultValue); } } -} \ No newline at end of file +} diff --git a/tests/DNX.Extensions.Tests/Conversion/GuidExtensionsTests.cs b/tests/DNX.Extensions.Tests/Conversion/GuidExtensionsTests.cs index b17896b..244101a 100644 --- a/tests/DNX.Extensions.Tests/Conversion/GuidExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Conversion/GuidExtensionsTests.cs @@ -1,6 +1,6 @@ using System.Security.Cryptography; using DNX.Extensions.Conversion; -using FluentAssertions; +using Shouldly; using Xunit; using Xunit.Abstractions; @@ -21,8 +21,8 @@ public void ToDeterministicGuid_can_create_a_guid_from_any_string(string text) outputHelper.WriteLine($"Text: {text} = {result}"); // Assert - result.Should().NotBe(Guid.Empty); - result.ToString().Should().NotBe(text); + result.ShouldNotBe(Guid.Empty); + result.ToString().ShouldNotBe(text); } [Theory] @@ -34,8 +34,8 @@ public void ToDeterministicGuid_can_create_a_guid_from_any_string_with_a_custom_ outputHelper.WriteLine($"Text: {text} = {result}"); // Assert - result.Should().NotBe(Guid.Empty); - result.ToString().Should().NotBe(text); + result.ShouldNotBe(Guid.Empty); + result.ToString().ShouldNotBe(text); } [Theory] @@ -53,10 +53,10 @@ public void ToDeterministicGuid_will_always_generate_a_predictable_result(string outputHelper.WriteLine($"Text: {text} = {result}"); // Assert - result.Should().NotBe(Guid.Empty); - result.ToString().Should().NotBe(text); - result.Should().Be(result2); - result.ToString().Should().Be(expected); + result.ShouldNotBe(Guid.Empty); + result.ToString().ShouldNotBe(text); + result.ShouldBe(result2); + result.ToString().ShouldBe(expected); } // Useful : https://www.compscilib.com/calculate/binaryxor?variation=default diff --git a/tests/DNX.Extensions.Tests/DNX.Extensions.Tests.csproj b/tests/DNX.Extensions.Tests/DNX.Extensions.Tests.csproj index 26fc323..8bc5555 100644 --- a/tests/DNX.Extensions.Tests/DNX.Extensions.Tests.csproj +++ b/tests/DNX.Extensions.Tests/DNX.Extensions.Tests.csproj @@ -28,9 +28,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all diff --git a/tests/DNX.Extensions.Tests/DateTimes/DateTimeExtensionsTests.cs b/tests/DNX.Extensions.Tests/DateTimes/DateTimeExtensionsTests.cs index 8573e89..775b279 100644 --- a/tests/DNX.Extensions.Tests/DateTimes/DateTimeExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/DateTimes/DateTimeExtensionsTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.DateTimes; -using FluentAssertions; +using Shouldly; using Xunit; namespace DNX.Extensions.Tests.DateTimes; @@ -17,14 +17,14 @@ public void Unix_Epoch_returns_the_correct_value() var epoch = DateTimeExtensions.UnixEpoch; // Assert - epoch.Kind.Should().Be(DateTimeKind.Utc); - epoch.Year.Should().Be(1970); - epoch.Month.Should().Be(1); - epoch.Day.Should().Be(1); - epoch.Hour.Should().Be(0); - epoch.Minute.Should().Be(0); - epoch.Second.Should().Be(0); - epoch.Millisecond.Should().Be(0); + epoch.Kind.ShouldBe(DateTimeKind.Utc); + epoch.Year.ShouldBe(1970); + epoch.Month.ShouldBe(1); + epoch.Day.ShouldBe(1); + epoch.Hour.ShouldBe(0); + epoch.Minute.ShouldBe(0); + epoch.Second.ShouldBe(0); + epoch.Millisecond.ShouldBe(0); } [Fact] @@ -38,15 +38,15 @@ public void ParseDateAsUtc_can_parse_a_date() var parsedDateTime = dateTimeString.ParseDateAsUtc(); // Assert - theDateTime.Kind.Should().Be(DateTimeKind.Local); - parsedDateTime.Kind.Should().Be(DateTimeKind.Utc); - parsedDateTime.Year.Should().Be(theDateTime.Year); - parsedDateTime.Month.Should().Be(theDateTime.Month); - parsedDateTime.Day.Should().Be(theDateTime.Day); - parsedDateTime.Hour.Should().Be(theDateTime.Hour); - parsedDateTime.Minute.Should().Be(theDateTime.Minute); - parsedDateTime.Second.Should().Be(theDateTime.Second); - parsedDateTime.Millisecond.Should().Be(0); + theDateTime.Kind.ShouldBe(DateTimeKind.Local); + parsedDateTime.Kind.ShouldBe(DateTimeKind.Utc); + parsedDateTime.Year.ShouldBe(theDateTime.Year); + parsedDateTime.Month.ShouldBe(theDateTime.Month); + parsedDateTime.Day.ShouldBe(theDateTime.Day); + parsedDateTime.Hour.ShouldBe(theDateTime.Hour); + parsedDateTime.Minute.ShouldBe(theDateTime.Minute); + parsedDateTime.Second.ShouldBe(theDateTime.Second); + parsedDateTime.Millisecond.ShouldBe(0); } [Fact] @@ -61,14 +61,14 @@ public void ParseDateAsUtc_with_default_value_can_parse_a_date() var parsedDateTime = dateTimeString.ParseDateAsUtc(defaultDateTime); // Assert - parsedDateTime.Kind.Should().Be(DateTimeKind.Utc); - parsedDateTime.Year.Should().Be(theDateTime.Year); - parsedDateTime.Month.Should().Be(theDateTime.Month); - parsedDateTime.Day.Should().Be(theDateTime.Day); - parsedDateTime.Hour.Should().Be(theDateTime.Hour); - parsedDateTime.Minute.Should().Be(theDateTime.Minute); - parsedDateTime.Second.Should().Be(theDateTime.Second); - parsedDateTime.Millisecond.Should().Be(0); + parsedDateTime.Kind.ShouldBe(DateTimeKind.Utc); + parsedDateTime.Year.ShouldBe(theDateTime.Year); + parsedDateTime.Month.ShouldBe(theDateTime.Month); + parsedDateTime.Day.ShouldBe(theDateTime.Day); + parsedDateTime.Hour.ShouldBe(theDateTime.Hour); + parsedDateTime.Minute.ShouldBe(theDateTime.Minute); + parsedDateTime.Second.ShouldBe(theDateTime.Second); + parsedDateTime.Millisecond.ShouldBe(0); } [Fact] @@ -82,14 +82,14 @@ public void ParseDateAsUtc_with_default_value_returns_default_value_when_it_fail var parsedDateTime = dateTimeString.ParseDateAsUtc(defaultDateTime); // Assert - parsedDateTime.Kind.Should().Be(DateTimeKind.Utc); - parsedDateTime.Year.Should().Be(defaultDateTime.Year); - parsedDateTime.Month.Should().Be(defaultDateTime.Month); - parsedDateTime.Day.Should().Be(defaultDateTime.Day); - parsedDateTime.Hour.Should().Be(defaultDateTime.Hour); - parsedDateTime.Minute.Should().Be(defaultDateTime.Minute); - parsedDateTime.Second.Should().Be(defaultDateTime.Second); - parsedDateTime.Millisecond.Should().Be(defaultDateTime.Millisecond); + parsedDateTime.Kind.ShouldBe(DateTimeKind.Utc); + parsedDateTime.Year.ShouldBe(defaultDateTime.Year); + parsedDateTime.Month.ShouldBe(defaultDateTime.Month); + parsedDateTime.Day.ShouldBe(defaultDateTime.Day); + parsedDateTime.Hour.ShouldBe(defaultDateTime.Hour); + parsedDateTime.Minute.ShouldBe(defaultDateTime.Minute); + parsedDateTime.Second.ShouldBe(defaultDateTime.Second); + parsedDateTime.Millisecond.ShouldBe(defaultDateTime.Millisecond); } [Fact] @@ -105,15 +105,15 @@ public void ParseDateAsUtc_can_parse_a_date_using_a_format_provider() var parsedDateTime = dateTimeString.ParseDateAsUtc(formatProvider); // Assert - theDateTime.Kind.Should().Be(DateTimeKind.Local); - parsedDateTime.Kind.Should().Be(DateTimeKind.Utc); - parsedDateTime.Year.Should().Be(theDateTime.Year); - parsedDateTime.Month.Should().Be(theDateTime.Month); - parsedDateTime.Day.Should().Be(theDateTime.Day); - parsedDateTime.Hour.Should().Be(theDateTime.Hour); - parsedDateTime.Minute.Should().Be(theDateTime.Minute); - parsedDateTime.Second.Should().Be(theDateTime.Second); - parsedDateTime.Millisecond.Should().Be(0); + theDateTime.Kind.ShouldBe(DateTimeKind.Local); + parsedDateTime.Kind.ShouldBe(DateTimeKind.Utc); + parsedDateTime.Year.ShouldBe(theDateTime.Year); + parsedDateTime.Month.ShouldBe(theDateTime.Month); + parsedDateTime.Day.ShouldBe(theDateTime.Day); + parsedDateTime.Hour.ShouldBe(theDateTime.Hour); + parsedDateTime.Minute.ShouldBe(theDateTime.Minute); + parsedDateTime.Second.ShouldBe(theDateTime.Second); + parsedDateTime.Millisecond.ShouldBe(0); } [Fact] @@ -130,14 +130,14 @@ public void ParseDateAsUtc_with_default_value_returns_can_parse_a_date_using_a_f var parsedDateTime = dateTimeString.ParseDateAsUtc(formatProvider, defaultDateTime); // Assert - parsedDateTime.Kind.Should().Be(DateTimeKind.Utc); - parsedDateTime.Year.Should().Be(theDateTime.Year); - parsedDateTime.Month.Should().Be(theDateTime.Month); - parsedDateTime.Day.Should().Be(theDateTime.Day); - parsedDateTime.Hour.Should().Be(theDateTime.Hour); - parsedDateTime.Minute.Should().Be(theDateTime.Minute); - parsedDateTime.Second.Should().Be(theDateTime.Second); - parsedDateTime.Millisecond.Should().Be(0); + parsedDateTime.Kind.ShouldBe(DateTimeKind.Utc); + parsedDateTime.Year.ShouldBe(theDateTime.Year); + parsedDateTime.Month.ShouldBe(theDateTime.Month); + parsedDateTime.Day.ShouldBe(theDateTime.Day); + parsedDateTime.Hour.ShouldBe(theDateTime.Hour); + parsedDateTime.Minute.ShouldBe(theDateTime.Minute); + parsedDateTime.Second.ShouldBe(theDateTime.Second); + parsedDateTime.Millisecond.ShouldBe(0); } [Fact] @@ -153,14 +153,14 @@ public void ParseDateAsUtc_with_default_value_returns_default_value_when_it_fail var parsedDateTime = dateTimeString.ParseDateAsUtc(formatProvider, defaultDateTime); // Assert - parsedDateTime.Kind.Should().Be(DateTimeKind.Utc); - parsedDateTime.Year.Should().Be(defaultDateTime.Year); - parsedDateTime.Month.Should().Be(defaultDateTime.Month); - parsedDateTime.Day.Should().Be(defaultDateTime.Day); - parsedDateTime.Hour.Should().Be(defaultDateTime.Hour); - parsedDateTime.Minute.Should().Be(defaultDateTime.Minute); - parsedDateTime.Second.Should().Be(defaultDateTime.Second); - parsedDateTime.Millisecond.Should().Be(defaultDateTime.Millisecond); + parsedDateTime.Kind.ShouldBe(DateTimeKind.Utc); + parsedDateTime.Year.ShouldBe(defaultDateTime.Year); + parsedDateTime.Month.ShouldBe(defaultDateTime.Month); + parsedDateTime.Day.ShouldBe(defaultDateTime.Day); + parsedDateTime.Hour.ShouldBe(defaultDateTime.Hour); + parsedDateTime.Minute.ShouldBe(defaultDateTime.Minute); + parsedDateTime.Second.ShouldBe(defaultDateTime.Second); + parsedDateTime.Millisecond.ShouldBe(defaultDateTime.Millisecond); } @@ -175,9 +175,9 @@ public void SetYear_can_operate_as_expected(DateTime dateTime) var result = dateTime.SetYear(year); - result.Year.Should().Be(year); - result.Month.Should().Be(month); - result.Day.Should().Be(day); + result.Year.ShouldBe(year); + result.Month.ShouldBe(month); + result.Day.ShouldBe(day); } [Theory] @@ -190,9 +190,9 @@ public void SetMonth_can_operate_as_expected(DateTime dateTime) var result = dateTime.SetMonth(month); - result.Year.Should().Be(year); - result.Month.Should().Be(month); - result.Day.Should().Be(day); + result.Year.ShouldBe(year); + result.Month.ShouldBe(month); + result.Day.ShouldBe(day); } [Theory] @@ -205,9 +205,9 @@ public void SetDay_can_operate_as_expected(DateTime dateTime) var result = dateTime.SetDay(day); - result.Year.Should().Be(year); - result.Month.Should().Be(month); - result.Day.Should().Be(day); + result.Year.ShouldBe(year); + result.Month.ShouldBe(month); + result.Day.ShouldBe(day); } [Theory] @@ -216,7 +216,7 @@ public void ResetHours_can_operate_as_expected(DateTime dateTime) { var result = dateTime.ResetHours(); - result.Hour.Should().Be(0); + result.Hour.ShouldBe(0); } [Theory] @@ -225,7 +225,7 @@ public void ResetMinutes_can_operate_as_expected(DateTime dateTime) { var result = dateTime.ResetMinutes(); - result.Minute.Should().Be(0); + result.Minute.ShouldBe(0); } [Theory] @@ -234,7 +234,7 @@ public void ResetSeconds_can_operate_as_expected(DateTime dateTime) { var result = dateTime.ResetSeconds(); - result.Second.Should().Be(0); + result.Second.ShouldBe(0); } [Theory] @@ -243,7 +243,7 @@ public void ResetMilliseconds_can_operate_as_expected(DateTime dateTime) { var result = dateTime.ResetMilliseconds(); - result.Millisecond.Should().Be(0); + result.Millisecond.ShouldBe(0); } [Theory] @@ -254,7 +254,7 @@ public void SetHours_can_operate_as_expected(DateTime dateTime) var result = dateTime.SetHours(value); - result.Hour.Should().Be(value); + result.Hour.ShouldBe(value); } [Theory] @@ -265,7 +265,7 @@ public void SetMinutes_can_operate_as_expected(DateTime dateTime) var result = dateTime.SetMinutes(value); - result.Minute.Should().Be(value); + result.Minute.ShouldBe(value); } [Theory] @@ -276,7 +276,7 @@ public void SetSeconds_can_operate_as_expected(DateTime dateTime) var result = dateTime.SetSeconds(value); - result.Second.Should().Be(value); + result.Second.ShouldBe(value); } [Theory] @@ -287,7 +287,7 @@ public void SetMilliseconds_can_operate_as_expected(DateTime dateTime) var result = dateTime.SetMilliseconds(value); - result.Millisecond.Should().Be(value); + result.Millisecond.ShouldBe(value); } public static TheoryData ResetDateTime_Data() diff --git a/tests/DNX.Extensions.Tests/Dictionaries/DictionaryExtensionsTests.cs b/tests/DNX.Extensions.Tests/Dictionaries/DictionaryExtensionsTests.cs index 80edfc0..6aa0610 100644 --- a/tests/DNX.Extensions.Tests/Dictionaries/DictionaryExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Dictionaries/DictionaryExtensionsTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Dictionaries; -using FluentAssertions; +using Shouldly; using Xunit; namespace DNX.Extensions.Tests.Dictionaries; @@ -25,7 +25,7 @@ public void Can_get_dictionary_value_safely_or_default(string key, int expectedV var value = dict.Get(key); // Assert - value.Should().Be(expectedValue); + value.ShouldBe(expectedValue); } [Theory] @@ -46,7 +46,7 @@ public void Can_get_dictionary_value_safely_overriding_default(string key, int d var value = dict.Get(key, defaultValue); // Assert - value.Should().Be(expectedValue); + value.ShouldBe(expectedValue); } [Fact] @@ -59,13 +59,13 @@ public void Can_split_well_formed_string_into_string_dictionary() var result = text.ToStringDictionary(); // Assert - result.Should().NotBeNull(); - result.Should().BeOfType(typeof(Dictionary)); - result.Keys.Count.Should().Be(2); - result.ContainsKey("Liverpool").Should().Be(true); - result["Liverpool"].Should().Be("1"); - result.ContainsKey("Southend United").Should().Be(true); - result["Southend United"].Should().Be("7"); + result.ShouldNotBeNull(); + result.ShouldBeOfType(typeof(Dictionary)); + result.Keys.Count.ShouldBe(2); + result.ContainsKey("Liverpool").ShouldBe(true); + result["Liverpool"].ShouldBe("1"); + result.ContainsKey("Southend United").ShouldBe(true); + result["Southend United"].ShouldBe("7"); } [Fact] @@ -78,9 +78,9 @@ public void Null_string_is_handled_into_string_dictionary() var result = text.ToStringDictionary(); // Assert - result.Should().NotBeNull(); - result.Should().BeOfType(typeof(Dictionary)); - result.Keys.Count.Should().Be(0); + result.ShouldNotBeNull(); + result.ShouldBeOfType(typeof(Dictionary)); + result.Keys.Count.ShouldBe(0); } [Fact] @@ -93,12 +93,12 @@ public void Can_split_well_formed_string_into_string_object_dictionary() var result = text.ToStringObjectDictionary(); // Assert - result.Should().NotBeNull(); - result.Should().BeOfType(typeof(Dictionary)); - result.Keys.Count.Should().Be(2); - result.ContainsKey("Liverpool").Should().Be(true); - result["Liverpool"].Should().Be("1"); - result.ContainsKey("Southend United").Should().Be(true); - result["Southend United"].Should().Be("7"); + result.ShouldNotBeNull(); + result.ShouldBeOfType(typeof(Dictionary)); + result.Keys.Count.ShouldBe(2); + result.ContainsKey("Liverpool").ShouldBe(true); + result["Liverpool"].ShouldBe("1"); + result.ContainsKey("Southend United").ShouldBe(true); + result["Southend United"].ShouldBe("7"); } } \ No newline at end of file diff --git a/tests/DNX.Extensions.Tests/Enums/EnumExtensionsTests.cs b/tests/DNX.Extensions.Tests/Enums/EnumExtensionsTests.cs index fedee9b..65c362c 100644 --- a/tests/DNX.Extensions.Tests/Enums/EnumExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Enums/EnumExtensionsTests.cs @@ -1,6 +1,6 @@ using System.ComponentModel; using DNX.Extensions.Enumerations; -using FluentAssertions; +using Shouldly; using Xunit; namespace DNX.Extensions.Tests.Enums; @@ -36,7 +36,7 @@ public void GetDescription_can_retrieve_value_correctly(MyType myType, string ex var result = myType.GetDescription(); // Assert - result.Should().Be(expectedResult, $"{myType} has description: {result}"); + result.ShouldBe(expectedResult, $"{myType} has description: {result}"); } [Theory] @@ -51,6 +51,6 @@ public void GetDescriptionOrName_can_retrieve_value_correctly(MyType myType, str var result = myType.GetDescriptionOrName(); // Assert - result.Should().Be(expectedResult, $"{myType} has description: {result}"); + result.ShouldBe(expectedResult, $"{myType} has description: {result}"); } } \ No newline at end of file diff --git a/tests/DNX.Extensions.Tests/Execution/RunSafelyTests.cs b/tests/DNX.Extensions.Tests/Execution/RunSafelyTests.cs index 32936a5..e527fe8 100644 --- a/tests/DNX.Extensions.Tests/Execution/RunSafelyTests.cs +++ b/tests/DNX.Extensions.Tests/Execution/RunSafelyTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Execution; -using FluentAssertions; +using Shouldly; using Xunit; // ReSharper disable PreferConcreteValueOverDefault @@ -22,7 +22,7 @@ public void Can_run_simple_action_that_succeeds() RunSafely.Execute(() => value = guid); // Assert - value.Should().Be(guid); + value.ShouldBe(guid); } [Fact] @@ -44,9 +44,9 @@ public void Can_handle_simple_action_that_fails_and_extract_exception() RunSafely.Execute(() => throw new Exception(guid.ToString()), ex => message = ex.Message); // Assert - value.Should().Be(int.MaxValue); - message.Should().NotBeNull(); - message.Should().NotBeNull(guid.ToString()); + value.ShouldBe(int.MaxValue); + message.ShouldNotBeNull(); + message.ShouldNotBeNull(guid.ToString()); } [Fact] @@ -61,7 +61,7 @@ public void Can_handle_simple_func_that_fails() RunSafely.Execute(() => value = dividend / divisor); // Assert - value.Should().Be(0); + value.ShouldBe(0); } [Fact] @@ -77,9 +77,9 @@ public void Can_handle_simple_func_that_fails_and_extract_exception() RunSafely.Execute(() => value = dividend / divisor, ex => message = ex.Message); // Assert - value.Should().Be(0); - message.Should().NotBeNullOrEmpty(); - message.Should().Contain("divide by zero"); + value.ShouldBe(0); + message.ShouldNotBeNullOrEmpty(); + message.ShouldContain("divide by zero"); } } @@ -95,7 +95,7 @@ public void Can_run_simple_func_that_succeeds() var value = RunSafely.Execute(() => guid); // Assert - value.Should().Be(guid); + value.ShouldBe(guid); } [Fact] @@ -109,7 +109,7 @@ public void Can_handle_simple_func_that_fails() var value = RunSafely.Execute(() => dividend / divisor); // Assert - value.Should().Be(default); + value.ShouldBe(default); } [Fact] @@ -124,7 +124,7 @@ public void Can_handle_simple_func_with_default_that_fails() var value = RunSafely.Execute(() => dividend / divisor, defaultResult); // Assert - value.Should().Be(defaultResult); + value.ShouldBe(defaultResult); } [Fact] @@ -139,9 +139,9 @@ public void Can_handle_simple_func_that_fails_and_extract_exception() var value = RunSafely.Execute(() => dividend / divisor, ex => message = ex.Message); // Assert - value.Should().Be(default); - message.Should().NotBeNullOrEmpty(); - message.Should().Contain("divide by zero"); + value.ShouldBe(default); + message.ShouldNotBeNullOrEmpty(); + message.ShouldContain("divide by zero"); } [Fact] @@ -157,9 +157,9 @@ public void Can_handle_simple_func_with_default_that_fails_and_extract_exception var value = RunSafely.Execute(() => dividend / divisor, defaultResult, ex => message = ex.Message); // Assert - value.Should().Be(defaultResult); - message.Should().NotBeNullOrEmpty(); - message.Should().Contain("divide by zero"); + value.ShouldBe(defaultResult); + message.ShouldNotBeNullOrEmpty(); + message.ShouldContain("divide by zero"); } } @@ -180,7 +180,7 @@ public async Task Can_run_simple_task_that_succeeds() await RunSafely.ExecuteAsync(task); // Assert - value.Should().Be(dividend / divisor); + value.ShouldBe(dividend / divisor); } [Fact] @@ -198,7 +198,7 @@ public async Task Can_handle_simple_action_that_fails() await RunSafely.ExecuteAsync(task); // Assert - value.Should().Be(0); + value.ShouldBe(0); } [Fact] @@ -217,9 +217,9 @@ public async Task Can_handle_simple_action_that_fails_and_extract_exception() await RunSafely.ExecuteAsync(task, ex => message = ex.Message); // Assert - value.Should().Be(0); - message.Should().NotBeNullOrEmpty(); - message.Should().Contain("divide by zero"); + value.ShouldBe(0); + message.ShouldNotBeNullOrEmpty(); + message.ShouldContain("divide by zero"); } } @@ -243,7 +243,7 @@ public async Task Can_run_simple_func_that_succeeds() var value = await RunSafely.ExecuteAsync(DivideAsync(dividend, divisor)); // Assert - value.Should().Be(dividend / divisor); + value.ShouldBe(dividend / divisor); } [Fact] @@ -258,7 +258,7 @@ public async Task Can_run_simple_func_that_fails() value = await RunSafely.ExecuteAsync(DivideAsync(dividend, divisor)); // Assert - value.Should().Be(default); + value.ShouldBe(default); } [Fact] @@ -274,7 +274,7 @@ public async Task Can_run_simple_func_with_default_that_fails() value = await RunSafely.ExecuteAsync(DivideAsync(dividend, divisor), defaultResult); // Assert - value.Should().Be(defaultResult); + value.ShouldBe(defaultResult); } [Fact] @@ -290,9 +290,9 @@ public async Task Can_handle_simple_func_that_fails_and_extract_exception() value = await RunSafely.ExecuteAsync(DivideAsync(dividend, divisor), ex => message = ex.Message); // Assert - value.Should().Be(default); - message.Should().NotBeNull(); - message.Should().NotBeNull("divide by zero"); + value.ShouldBe(default); + message.ShouldNotBeNull(); + message.ShouldNotBeNull("divide by zero"); } [Fact] @@ -310,9 +310,9 @@ public async Task Can_handle_simple_func_with_default_that_fails_and_extract_exc ex => message = ex.Message); // Assert - value.Should().Be(defaultResult); - message.Should().NotBeNull(); - message.Should().Contain("divide by zero"); + value.ShouldBe(defaultResult); + message.ShouldNotBeNull(); + message.ShouldContain("divide by zero"); } } } diff --git a/tests/DNX.Extensions.Tests/IO/DirectoryInfoExtensionsTests.cs b/tests/DNX.Extensions.Tests/IO/DirectoryInfoExtensionsTests.cs index 3ba5a58..4412448 100644 --- a/tests/DNX.Extensions.Tests/IO/DirectoryInfoExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/IO/DirectoryInfoExtensionsTests.cs @@ -1,6 +1,6 @@ using DNX.Extensions.IO; using DNX.Extensions.Strings; -using FluentAssertions; +using Shouldly; using Xunit; using Xunit.Abstractions; @@ -65,8 +65,8 @@ public void FindFiles_for_directory_that_does_not_exist_finds_expected_files() var result = directoryInfo.FindFiles(pattern, false); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(0); + result.ShouldNotBeNull(); + result.Count().ShouldBe(0); } [Fact] @@ -79,9 +79,9 @@ public void FindFiles_for_single_pattern_without_recursion_finds_expected_files( var result = _directoryInfo.FindFiles(pattern, false); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(1); - result.Count(x => x.Name == "file.txt").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(1); + result.Count(x => x.Name == "file.txt").ShouldBe(1); } [Fact] @@ -94,11 +94,11 @@ public void FindFiles_for_single_pattern_with_recursion_finds_expected_files() var result = _directoryInfo.FindFiles(pattern, true); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(3); - result.Count(x => x.Name == "file.txt").Should().Be(1); - result.Count(x => x.Name == "file1.txt").Should().Be(1); - result.Count(x => x.Name == "file2.txt").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(3); + result.Count(x => x.Name == "file.txt").ShouldBe(1); + result.Count(x => x.Name == "file1.txt").ShouldBe(1); + result.Count(x => x.Name == "file2.txt").ShouldBe(1); } [Fact] @@ -112,10 +112,10 @@ public void FindFiles_for_multiple_patterns_without_recursion_finds_expected_fil var result = _directoryInfo.FindFiles(patterns, false); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(2); - result.Count(x => x.Name == "file.txt").Should().Be(1); - result.Count(x => x.Name == "file.json").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(2); + result.Count(x => x.Name == "file.txt").ShouldBe(1); + result.Count(x => x.Name == "file.json").ShouldBe(1); } [Fact] @@ -129,14 +129,14 @@ public void FindFiles_for_multiple_patterns_with_recursion_finds_expected_files( var result = _directoryInfo.FindFiles(patterns, true); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(6); - result.Count(x => x.Name == "file.txt").Should().Be(1); - result.Count(x => x.Name == "file1.txt").Should().Be(1); - result.Count(x => x.Name == "file2.txt").Should().Be(1); - result.Count(x => x.Name == "file.json").Should().Be(1); - result.Count(x => x.Name == "file1.json").Should().Be(1); - result.Count(x => x.Name == "file2.json").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(6); + result.Count(x => x.Name == "file.txt").ShouldBe(1); + result.Count(x => x.Name == "file1.txt").ShouldBe(1); + result.Count(x => x.Name == "file2.txt").ShouldBe(1); + result.Count(x => x.Name == "file.json").ShouldBe(1); + result.Count(x => x.Name == "file1.json").ShouldBe(1); + result.Count(x => x.Name == "file2.json").ShouldBe(1); } [Fact] @@ -150,8 +150,8 @@ public void FindDirectories_for_directory_that_does_not_exist_finds_expected_fil var result = directoryInfo.FindDirectories(pattern, false); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(0); + result.ShouldNotBeNull(); + result.Count().ShouldBe(0); } [Fact] @@ -164,10 +164,10 @@ public void FindDirectories_for_single_pattern_without_recursion_finds_expected_ var result = _directoryInfo.FindDirectories(pattern, false); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(2); - result.Count(x => x.Name == "dir1").Should().Be(1); - result.Count(x => x.Name == "dir2").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(2); + result.Count(x => x.Name == "dir1").ShouldBe(1); + result.Count(x => x.Name == "dir2").ShouldBe(1); } [Fact] @@ -180,12 +180,12 @@ public void FindDirectories_for_single_pattern_with_recursion_finds_expected_fil var result = _directoryInfo.FindDirectories(pattern, true); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(4); - result.Count(x => x.Name == "dir1").Should().Be(1); - result.Count(x => x.Name == "dir2").Should().Be(1); - result.Count(x => x.Name == "dur3").Should().Be(1); - result.Count(x => x.Name == "dur4").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(4); + result.Count(x => x.Name == "dir1").ShouldBe(1); + result.Count(x => x.Name == "dir2").ShouldBe(1); + result.Count(x => x.Name == "dur3").ShouldBe(1); + result.Count(x => x.Name == "dur4").ShouldBe(1); } [Fact] @@ -198,10 +198,10 @@ public void FindDirectories_for_multiple_patterns_without_recursion_finds_expect var result = _directoryInfo.FindDirectories(patterns, false); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(2); - result.Count(x => x.Name == "dir1").Should().Be(1); - result.Count(x => x.Name == "dir2").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(2); + result.Count(x => x.Name == "dir1").ShouldBe(1); + result.Count(x => x.Name == "dir2").ShouldBe(1); } [Fact] @@ -214,12 +214,12 @@ public void FindDirectories_for_multiple_patterns_with_recursion_finds_expected_ var result = _directoryInfo.FindDirectories(patterns, true); // Assert - result.Should().NotBeNull(); - result.Count().Should().Be(4); - result.Count(x => x.Name == "dir1").Should().Be(1); - result.Count(x => x.Name == "dir2").Should().Be(1); - result.Count(x => x.Name == "dur3").Should().Be(1); - result.Count(x => x.Name == "dur4").Should().Be(1); + result.ShouldNotBeNull(); + result.Count().ShouldBe(4); + result.Count(x => x.Name == "dir1").ShouldBe(1); + result.Count(x => x.Name == "dir2").ShouldBe(1); + result.Count(x => x.Name == "dur3").ShouldBe(1); + result.Count(x => x.Name == "dur4").ShouldBe(1); } [Theory] @@ -233,7 +233,7 @@ public void GetRelativePath_can_extract_relative_path_correctly(string dirName, var result = dirInfo.GetRelativePath(relativeToDirInfo); - result.Should().Be(expected, $"{nameof(dirName)}: {dirName} - {nameof(relativeToDirInfo)}: {relativeToDirInfo}"); + result.ShouldBe(expected, $"{nameof(dirName)}: {dirName} - {nameof(relativeToDirInfo)}: {relativeToDirInfo}"); } public static TheoryData GetRelativePath_Data() diff --git a/tests/DNX.Extensions.Tests/IO/FileInfoExtensionsTests.cs b/tests/DNX.Extensions.Tests/IO/FileInfoExtensionsTests.cs index 140391f..ea91b89 100644 --- a/tests/DNX.Extensions.Tests/IO/FileInfoExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/IO/FileInfoExtensionsTests.cs @@ -1,6 +1,6 @@ using DNX.Extensions.IO; using DNX.Extensions.Strings; -using FluentAssertions; +using Shouldly; using Xunit; using Xunit.Abstractions; @@ -39,7 +39,7 @@ public void GetRelativeFileName_can_extract_relative_filename_correctly(string f var result = fileInfo.GetRelativeFileName(dirInfo); - result.Should().Be(expected, $"{nameof(dirName)}: {dirName} - {nameof(fileName)}: {fileName}"); + result.ShouldBe(expected, $"{nameof(dirName)}: {dirName} - {nameof(fileName)}: {fileName}"); } [Theory] @@ -53,7 +53,7 @@ public void GetRelativeFilePath_can_extract_relative_path_correctly(string fileN var result = fileInfo.GetRelativeFilePath(dirInfo); - result.Should().Be(expected, $"{nameof(dirName)}: {dirName} - {nameof(fileName)}: {fileName}"); + result.ShouldBe(expected, $"{nameof(dirName)}: {dirName} - {nameof(fileName)}: {fileName}"); } [Theory] @@ -62,7 +62,7 @@ public void GetFriendlyFileSize_given_a_fileSize_should_return_expected_text(lon { var result = FileInfoExtensions.GetFriendlyFileSize(fileSize); - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -75,7 +75,7 @@ public void GetFriendlyFileSize_given_an_invalid_FileInfo_should_return_expected var result = FileInfoExtensions.GetFriendlyFileSize(fileInfo); // Assert - result.Should().Be("0B"); + result.ShouldBe("0B"); } [Theory] @@ -93,7 +93,7 @@ public void GetFriendlyFileSize_given_a_valid_FileInfo_should_return_expected_te var result = FileInfoExtensions.GetFriendlyFileSize(fileInfo); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); // Cleanup fileInfo.Delete(); diff --git a/tests/DNX.Extensions.Tests/Linq/EnumerableExtensionsTests.cs b/tests/DNX.Extensions.Tests/Linq/EnumerableExtensionsTests.cs index 8fea594..0ecf9dd 100644 --- a/tests/DNX.Extensions.Tests/Linq/EnumerableExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Linq/EnumerableExtensionsTests.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; using DNX.Extensions.Linq; -using FluentAssertions; +using Shouldly; using Xunit; using Xunit.Abstractions; @@ -34,7 +34,7 @@ public void Populated_Enumerable_returns_successfully_as_True(string itemList) var result = enumerable.HasAny(); // Assert - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -47,7 +47,7 @@ public void Empty_Enumerable_returns_successfully_as_False() var result = enumerable.HasAny(); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -60,7 +60,7 @@ public void Null_Enumerable_returns_successfully_as_False() var result = enumerable.HasAny(); // Assert - result.Should().BeFalse(); + result.ShouldBeFalse(); } } @@ -80,7 +80,7 @@ public void Test_HasAny_predicate(string commaDelimitedArray, string suffix, boo var result = enumerable.HasAny(s => s.EndsWith(suffix)); - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -92,7 +92,7 @@ public void IsOneOf_with_string_data_can_operate_as_expected(string[] list, stri { var result = candidate.IsOneOf(list); - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -101,69 +101,69 @@ public void IsOneOf_with_string_data_and_comparer_can_operate_as_expected(string { var result = candidate.IsOneOf(list, comparer); - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Fact] public void IsOneOf_with_params_can_operate_as_expected() { - ((string)null).IsOneOf().Should().Be(false); - ((string)null).IsOneOf((string[])null).Should().Be(false); - "Hello".IsOneOf((string[])null).Should().BeFalse(); - "Hello".IsOneOf().Should().Be(false); - "3".IsOneOf("1", "2", "3", "4", "5").Should().Be(true); - "6".IsOneOf("1", "2", "3", "4", "5").Should().Be(false); - "One".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(true); - "Two".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(true); - "Three".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(true); - "Four".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(true); - "Five".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(true); - "five".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(false); - "FIVE".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(false); - "Six".IsOneOf("One", "Two", "Three", "Four", "Five").Should().Be(false); - 1.IsOneOf(1, 2, 3, 4, 5).Should().Be(true); - 3.IsOneOf(1, 2, 3, 4, 5).Should().Be(true); - 5.IsOneOf(1, 2, 3, 4, 5).Should().Be(true); - 6.IsOneOf(1, 2, 3, 4, 5).Should().Be(false); - OneToFive.One.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).Should().Be(true); - OneToFive.Three.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).Should().Be(true); - OneToFive.Five.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).Should().Be(true); - OneToFive.Two.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).Should().Be(false); - ((OneToFive)100).IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).Should().Be(false); + ((string)null).IsOneOf().ShouldBe(false); + ((string)null).IsOneOf((string[])null).ShouldBe(false); + "Hello".IsOneOf((string[])null).ShouldBeFalse(); + "Hello".IsOneOf().ShouldBe(false); + "3".IsOneOf("1", "2", "3", "4", "5").ShouldBe(true); + "6".IsOneOf("1", "2", "3", "4", "5").ShouldBe(false); + "One".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Two".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Three".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Four".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Five".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(true); + "five".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(false); + "FIVE".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(false); + "Six".IsOneOf("One", "Two", "Three", "Four", "Five").ShouldBe(false); + 1.IsOneOf(1, 2, 3, 4, 5).ShouldBe(true); + 3.IsOneOf(1, 2, 3, 4, 5).ShouldBe(true); + 5.IsOneOf(1, 2, 3, 4, 5).ShouldBe(true); + 6.IsOneOf(1, 2, 3, 4, 5).ShouldBe(false); + OneToFive.One.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).ShouldBe(true); + OneToFive.Three.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).ShouldBe(true); + OneToFive.Five.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).ShouldBe(true); + OneToFive.Two.IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).ShouldBe(false); + ((OneToFive)100).IsOneOf(OneToFive.One, OneToFive.Three, OneToFive.Five).ShouldBe(false); } [Fact] public void IsOneOf_with_params_and_Comparer_can_operate_as_expected() { var comparer = StringComparer.FromComparison(StringComparison.CurrentCulture); - ((string)null).IsOneOf(comparer).Should().Be(false); - ((string)null).IsOneOf(comparer, null).Should().Be(false); - "Hello".IsOneOf((string[])null).Should().BeFalse(); - "Hello".IsOneOf().Should().Be(false); - "Hello".IsOneOf(comparer).Should().Be(false); - "3".IsOneOf(comparer, "1", "2", "3", "4", "5").Should().Be(true); - "6".IsOneOf(comparer, "1", "2", "3", "4", "5").Should().Be(false); - "One".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Two".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Three".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Four".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(false); - "FIVE".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(false); - "Six".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(false); + ((string)null).IsOneOf(comparer).ShouldBe(false); + ((string)null).IsOneOf(comparer, null).ShouldBe(false); + "Hello".IsOneOf((string[])null).ShouldBeFalse(); + "Hello".IsOneOf().ShouldBe(false); + "Hello".IsOneOf(comparer).ShouldBe(false); + "3".IsOneOf(comparer, "1", "2", "3", "4", "5").ShouldBe(true); + "6".IsOneOf(comparer, "1", "2", "3", "4", "5").ShouldBe(false); + "One".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Two".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Three".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Four".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(false); + "FIVE".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(false); + "Six".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(false); comparer = StringComparer.FromComparison(StringComparison.CurrentCultureIgnoreCase); - "Hello".IsOneOf(comparer).Should().Be(false); - "3".IsOneOf(comparer, "1", "2", "3", "4", "5").Should().Be(true); - "6".IsOneOf(comparer, "1", "2", "3", "4", "5").Should().Be(false); - "One".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Two".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Three".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Four".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "FIVE".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(true); - "Six".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").Should().Be(false); + "Hello".IsOneOf(comparer).ShouldBe(false); + "3".IsOneOf(comparer, "1", "2", "3", "4", "5").ShouldBe(true); + "6".IsOneOf(comparer, "1", "2", "3", "4", "5").ShouldBe(false); + "One".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Two".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Three".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Four".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "five".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "FIVE".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(true); + "Six".IsOneOf(comparer, "One", "Two", "Three", "Four", "Five").ShouldBe(false); } #region Test Data @@ -270,14 +270,14 @@ public void Populated_Enumerable_repeatedly_returns_an_item_successfully(string hitCounts[result]++; // Assert - result.Should().NotBeNullOrEmpty(); + result.ShouldNotBeNullOrEmpty(); }); // Assert foreach (var kvp in hitCounts) { testOutputHelper.WriteLine("HitCount [{0}]: {1}", kvp.Key, kvp.Value); - kvp.Value.Should().BeGreaterThan(0); + kvp.Value.ShouldBeGreaterThan(0); } } @@ -291,7 +291,7 @@ public void Empty_string_Enumerable_returns_default() var result = enumerable.GetRandomItem(); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -304,7 +304,7 @@ public void Null_string_Enumerable_returns_default() var result = enumerable.GetRandomItem(); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -317,7 +317,7 @@ public void Empty_int_Enumerable_returns_default() var result = enumerable.GetRandomItem(); // Assert - result.Should().Be(default); + result.ShouldBe(default); } [Fact] @@ -330,7 +330,7 @@ public void Null_int_Enumerable_returns_default() var result = enumerable.GetRandomItem(); // Assert - result.Should().Be(default); + result.ShouldBe(default); } } @@ -355,7 +355,7 @@ public void Populated_List_repeatedly_returns_an_item_successfully(string itemLi var result = items.GetAt(index); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Theory] @@ -377,7 +377,7 @@ public void Populated_Array_repeatedly_returns_an_item_successfully(string itemL var result = items.GetAt(index); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -391,7 +391,7 @@ public void Empty_IList_returns_default() var result = items.GetAt(0); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -404,7 +404,7 @@ public void Empty_Array_returns_default() var result = items.GetAt(0); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -417,7 +417,7 @@ public void Null_IList_returns_default() var result = items.GetAt(0); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -430,7 +430,7 @@ public void Null_Array_returns_default() var result = items.GetAt(0); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } } } \ No newline at end of file diff --git a/tests/DNX.Extensions.Tests/Reflection/ReflectionExtensionsTests.cs b/tests/DNX.Extensions.Tests/Reflection/ReflectionExtensionsTests.cs index f728082..af3f71e 100644 --- a/tests/DNX.Extensions.Tests/Reflection/ReflectionExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Reflection/ReflectionExtensionsTests.cs @@ -1,6 +1,6 @@ using System.Reflection; using DNX.Extensions.Reflection; -using FluentAssertions; +using Shouldly; using Xunit; #pragma warning disable CA1822 // Members can be static @@ -51,7 +51,7 @@ public void GetPrivatePropertyValue_can_read_private_values_successfully(string var result = instance.GetPrivatePropertyValue(propertyName); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Theory] @@ -65,7 +65,7 @@ public void GetPrivatePropertyValue_can_read_non_private_values_successfully(str var result = instance.GetPrivatePropertyValue(propertyName); // Assert - result.Should().Be(expected); + result.ShouldBe(expected); } [Fact] @@ -78,7 +78,7 @@ public void GetPropertyValueByName_can_read_private_static_values_successfully() var result = instance.GetPropertyValueByName("CurrentDirectory", BindingFlags.Static | BindingFlags.NonPublic); // Assert - result.Should().Be(Environment.CurrentDirectory); + result.ShouldBe(Environment.CurrentDirectory); } [Fact] @@ -91,7 +91,7 @@ public void GetPropertyValueByName_for_unknown_property_name_returns_null() var result = instance.GetPropertyValueByName(Guid.NewGuid().ToString(), BindingFlags.Static | BindingFlags.NonPublic); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -104,7 +104,7 @@ public void GetPropertyValueByName_for_property_name_without_getter_returns_null var result = instance.GetPropertyValueByName(nameof(TestClass.PublicSetOnly), BindingFlags.Instance | BindingFlags.Public); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -117,7 +117,7 @@ public void GetPrivatePropertyValue_for_unknown_property_name_returns_null() var result = instance.GetPrivatePropertyValue(Guid.NewGuid().ToString()); // Assert - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -131,6 +131,6 @@ public void GetPrivatePropertyValue_for_unknown_property_name_returns_default_va var result = instance.GetPrivatePropertyValue(Guid.NewGuid().ToString(), defaultValue); // Assert - result.Should().Be(defaultValue); + result.ShouldBe(defaultValue); } } diff --git a/tests/DNX.Extensions.Tests/Strings/ArgumentParserExtensionsTests.cs b/tests/DNX.Extensions.Tests/Strings/ArgumentParserExtensionsTests.cs index 80da711..37481b0 100644 --- a/tests/DNX.Extensions.Tests/Strings/ArgumentParserExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Strings/ArgumentParserExtensionsTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Strings; -using FluentAssertions; +using Shouldly; using Xunit; namespace DNX.Extensions.Tests.Strings; @@ -19,16 +19,16 @@ public void When_called_with_a_valid_simple_string_of_values(string text, int pa var result = text.ParseArguments(); // Assert - result.Should().NotBeNull(); - result.Count.Should().Be(parameterCount); + result.ShouldNotBeNull(); + result.Count.ShouldBe(parameterCount); var parameters = resultsByPipe.Split("|".ToCharArray()); - parameters.Length.Should().Be(parameterCount); + parameters.Length.ShouldBe(parameterCount); var parameterPosition = 0; foreach (var parameter in parameters) { - result[parameterPosition].Should().Be(parameter); + result[parameterPosition].ShouldBe(parameter); ++parameterPosition; } diff --git a/tests/DNX.Extensions.Tests/Strings/BuiltInTypesExtensionsTests.cs b/tests/DNX.Extensions.Tests/Strings/BuiltInTypesExtensionsTests.cs index 762ee78..34c2760 100644 --- a/tests/DNX.Extensions.Tests/Strings/BuiltInTypesExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Strings/BuiltInTypesExtensionsTests.cs @@ -1,5 +1,5 @@ using DNX.Extensions.Strings; -using FluentAssertions; +using Shouldly; using Xunit; // ReSharper disable StringLiteralTypo @@ -16,7 +16,7 @@ public void Test_ToText(bool value, string expectedResult) var result = value.ToText(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -27,7 +27,7 @@ public void Test_ToText_custom_text(bool value, string trueText, string falseTex var result = value.ToText(trueText, falseText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -38,7 +38,7 @@ public void Test_ToYesNo(bool value, string expectedResult) var result = value.ToYesNo(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -49,7 +49,7 @@ public void Test_ToHexString_Number(int number, string expectedHexString) { var result = number.ToHexString(); - result.Should().Be(expectedHexString); + result.ShouldBe(expectedHexString); } [Theory] @@ -60,6 +60,6 @@ public void Test_ToHexString_Number_with_format(int number, string format, strin { var result = number.ToHexString(format); - result.Should().Be(expectedHexString); + result.ShouldBe(expectedHexString); } } diff --git a/tests/DNX.Extensions.Tests/Strings/StringExtensionsTests.cs b/tests/DNX.Extensions.Tests/Strings/StringExtensionsTests.cs index fff3ae8..65f8b79 100644 --- a/tests/DNX.Extensions.Tests/Strings/StringExtensionsTests.cs +++ b/tests/DNX.Extensions.Tests/Strings/StringExtensionsTests.cs @@ -1,7 +1,7 @@ using System.Globalization; using System.Text; using DNX.Extensions.Strings; -using FluentAssertions; +using Shouldly; using Xunit; #pragma warning disable CA1861 // Arrays in InlineData @@ -23,7 +23,7 @@ public class IsNull public void Test_IsNullOrEmpty(string text, bool expectedResult) { // Assert - text.IsNullOrEmpty().Should().Be(expectedResult); + text.IsNullOrEmpty().ShouldBe(expectedResult); } [Theory] @@ -35,7 +35,7 @@ public void Test_IsNullOrEmpty(string text, bool expectedResult) [InlineData("ABC", false)] public void Test_IsNullOrWhiteSpace(string text, bool expectedResult) { - text.IsNullOrWhiteSpace().Should().Be(expectedResult); + text.IsNullOrWhiteSpace().ShouldBe(expectedResult); } } @@ -51,9 +51,9 @@ public void NullIfEmpty_evaluates_text_correctly(string text, bool isNull) var result = text.NullIfEmpty(); if (isNull) - result.Should().BeNull(); + result.ShouldBeNull(); else - result.Should().NotBeNull(); + result.ShouldNotBeNull(); } [Theory] @@ -66,9 +66,9 @@ public void NullIfEmptyOrWhitespace_evaluates_text_correctly(string text, bool i var result = text.NullIfEmptyOrWhitespace(); if (isNull) - result.Should().BeNull(); + result.ShouldBeNull(); else - result.Should().NotBeNull(); + result.ShouldNotBeNull(); } } @@ -91,7 +91,7 @@ public void Test_EnsureStartsWith(string text, string prefix, string expectedRes var result = text.EnsureStartsWith(prefix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -111,7 +111,7 @@ public void Test_EnsureEndsWith(string text, string suffix, string expectedResul var result = text.EnsureEndsWith(suffix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -125,7 +125,7 @@ public void Test_EnsureStartsAndEndsWith(string text, string prefixSuffix, strin var result = text.EnsureStartsAndEndsWith(prefixSuffix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -140,7 +140,7 @@ public void Test_EnsureStartsAndEndsWith_prefix_and_suffix(string text, string p var result = text.EnsureStartsAndEndsWith(prefix, suffix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -158,7 +158,7 @@ public void Test_RemoveStartsWith(string text, string prefix, string expectedRes var result = text.RemoveStartsWith(prefix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -174,7 +174,7 @@ public void Test_RemoveEndsWith(string text, string suffix, string expectedResul var result = text.RemoveEndsWith(suffix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -190,7 +190,7 @@ public void Test_RemoveStartsAndEndsWith(string text, string prefixSuffix, strin var result = text.RemoveStartsAndEndsWith(prefixSuffix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -206,7 +206,7 @@ public void Test_RemoveStartsAndEndsWith_prefix_and_suffix(string text, string p var result = text.RemoveStartsAndEndsWith(prefix, suffix); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -229,7 +229,7 @@ public void Test_Between(string text, string startText, string endText, string e var result = text.Between(startText, endText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -250,7 +250,7 @@ public void Test_BetweenFirstAndLast(string text, string startText, string endTe var result = text.BetweenFirstAndLast(startText, endText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -263,7 +263,7 @@ public void Test_Between_ComparisonType(string text, string startText, string en var result = text.Between(startText, endText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -282,7 +282,7 @@ public void Test_Before(string text, string endText, string expectedResult) var result = text.Before(endText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -295,7 +295,7 @@ public void Test_Before_ComparisonType(string text, string endText, StringCompar var result = text.Before(endText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -310,7 +310,7 @@ public void Test_BeforeLast(string text, string endText, string expectedResult) { var result = text.BeforeLast(endText); - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -323,7 +323,7 @@ public void Test_BeforeLast_ComparisonType(string text, string endText, StringCo var result = text.BeforeLast(endText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -343,7 +343,7 @@ public void Test_After(string text, string startText, string expectedResult) var result = text.After(startText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -357,7 +357,7 @@ public void Test_After_ComparisonType(string text, string startText, StringCompa var result = text.After(startText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -374,7 +374,7 @@ public void Test_AfterLast(string text, string startText, string expectedResult) var result = text.AfterLast(startText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -388,7 +388,7 @@ public void Test_AfterLast_ComparisonType(string text, string startText, StringC var result = text.AfterLast(startText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -408,7 +408,7 @@ public void Test_From(string text, string searchText, string expectedResult) var result = text.From(searchText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -425,7 +425,7 @@ public void Test_From_ComparisonType(string text, string searchText, StringCompa var result = text.From(searchText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -442,7 +442,7 @@ public void Test_FromLast(string text, string searchText, string expectedResult) var result = text.FromLast(searchText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -459,7 +459,7 @@ public void Test_FromLast_ComparisonType(string text, string searchText, StringC var result = text.FromLast(searchText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -479,7 +479,7 @@ public void Test_AsFarAs(string text, string searchText, string expectedResult) var result = text.AsFarAs(searchText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -496,7 +496,7 @@ public void Test_AsFarAs_ComparisonType(string text, string searchText, StringCo var result = text.AsFarAs(searchText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -513,7 +513,7 @@ public void Test_AsFarAsLast(string text, string searchText, string expectedResu var result = text.AsFarAsLast(searchText); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -530,7 +530,7 @@ public void Test_AsFarAsLast_ComparisonType(string text, string searchText, Stri var result = text.AsFarAsLast(searchText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -550,7 +550,7 @@ public void Test_ContainsText(string text, string searchText, StringComparison c var result = text.ContainsText(searchText, comparison); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -564,7 +564,7 @@ public void Test_ContainsOnly(string text, string characters, bool expectedResul var result = text.ContainsOnly(characters); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -578,7 +578,7 @@ public void Test_ContainsOnlyCharacterArray(string text, IList characters, var result = text.ContainsOnly(characters); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -592,7 +592,7 @@ public void Test_RemoveAny(string text, string charsToRemove, string expectedRes var result = text.RemoveAny(charsToRemove); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -621,7 +621,7 @@ public void Test_RemoveAny_char_array(string text, char[] charsToRemove, string var result = text.RemoveAny(charsToRemove); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -635,7 +635,7 @@ public void Test_RemoveAnyExcept(string text, string charsToKeep, string expecte var result = text.RemoveAnyExcept(charsToKeep); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -656,7 +656,7 @@ public void Test_RemoveAnyExcept_char_array(string text, char[] charsToKeep, str var result = text.RemoveAnyExcept(charsToKeep); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -695,7 +695,7 @@ public void Test_IsValidNumber_default_culture(string text, string cultureInfoNa var result = text.IsValidNumber(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } finally { @@ -732,7 +732,7 @@ public void Test_IsValidNumber(string text, string cultureInfoName, bool expecte var result = text.IsValidNumber(cultureInfo); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -749,7 +749,7 @@ public void Test_Reverse(string text, string expectedResult) var result = text.Reverse(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -766,7 +766,7 @@ public void Test_SplitText(string text, string delimiters, StringSplitOptions op var result = text.SplitText(delimiters, options); // Assert - string.Join(",", result).Should().Be(expectedResult); + string.Join(",", result).ShouldBe(expectedResult); } [Theory] @@ -784,7 +784,7 @@ public void Test_SplitText_DelimiterType(string text, string delimiters, StringS var result = text.SplitText(delimiters, options, delimiterType); // Assert - string.Join(",", result).Should().Be(expectedResult); + string.Join(",", result).ShouldBe(expectedResult); } [Fact] @@ -800,9 +800,11 @@ public void Test_SplitText_InvalidDelimiterType() ); // Assert - ex.Should().NotBeNull(); - ex.ParamName.Should().Be("delimiterType"); - ex.Message.Should().ContainAll(Enum.GetValues().Select(x => x.ToString())); + ex.ShouldNotBeNull(); + ex.ParamName.ShouldBe("delimiterType"); + Enum.GetValues() + .ToList() + .ForEach(x => ex.Message.ShouldContain(x.ToString())); } [Theory] @@ -817,7 +819,7 @@ public void Test_SplitByText(string text, string delimiters, StringSplitOptions var result = text.SplitByText(delimiters, options); // Assert - string.Join(",", result).Should().Be(expectedResult); + string.Join(",", result).ShouldBe(expectedResult); } [Theory] @@ -835,7 +837,7 @@ public void Test_SplitByText_ComplexDelimiter(string text, StringSplitOptions op var lines = adjustedText.SplitByText(delimiters, options, comparison); // Assert - string.Join("/", lines).Should().Be(expectedResult); + string.Join("/", lines).ShouldBe(expectedResult); } } @@ -860,7 +862,7 @@ public void Test_CoalesceNullWith_params(string text, string a, string b, string var result = text.CoalesceNullWith(a, b, c); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -889,7 +891,7 @@ public void Test_CoalesceNullWith_list(string text, string a, string b, string c var result = text.CoalesceNullWith(list); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -916,7 +918,7 @@ public void Test_CoalesceNull_list(string a, string b, string c, string expected var result = list.CoalesceNull(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -941,7 +943,7 @@ public void Test_CoalesceNullOrEmptyWith_params(string text, string a, string b, var result = text.CoalesceNullOrEmptyWith(a, b, c); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -970,7 +972,7 @@ public void Test_CoalesceNullOrEmptyWith_list(string text, string a, string b, s var result = text.CoalesceNullOrEmptyWith(list); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -997,7 +999,7 @@ public void Test_CoalesceNullOrEmpty_list(string a, string b, string c, string e var result = list.CoalesceNullOrEmpty(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -1022,7 +1024,7 @@ public void Test_CoalesceNullOrWhitespaceWith_params(string text, string a, stri var result = text.CoalesceNullOrWhitespaceWith(a, b, c); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -1051,7 +1053,7 @@ public void Test_CoalesceNullOrWhitespaceWith_list(string text, string a, string var result = text.CoalesceNullOrWhitespaceWith(list); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -1078,7 +1080,7 @@ public void Test_CoalesceNullOrWhitespace_list(string a, string b, string c, str var result = list.CoalesceNullOrWhitespace(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -1103,7 +1105,7 @@ public void Wordify_Tests(string text, string expectedResult) var result = text.Wordify(); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } [Theory] @@ -1136,7 +1138,7 @@ public void Wordify_with_reserved_words_Tests(string text, string reservedWordsT var result = text.Wordify(reservedWordsList); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -1155,7 +1157,7 @@ public void Test_Left(string text, int length, string expectedResult) var result = text.Left(length); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -1174,7 +1176,7 @@ public void Test_Right(string text, int length, string expectedResult) var result = text.Right(length); // Assert - result.Should().Be(expectedResult); + result.ShouldBe(expectedResult); } } @@ -1186,7 +1188,7 @@ public void Test_ToHexString(string number, string expectedHexString) { var result = number.ToHexString(); - result.Should().Be(expectedHexString); + result.ShouldBe(expectedHexString); } } @@ -1201,7 +1203,7 @@ public void Test_GetBytes(string text, string expectedBytesText) var bytesText = string.Join(",", bytes.Select(x => x.ToString())); - bytesText.Should().Be(expectedBytesText); + bytesText.ShouldBe(expectedBytesText); } [Theory] @@ -1211,7 +1213,7 @@ public void Test_GetBytes_with_encoding(string text, Encoding encoding, byte[] e // Act var result = text.GetBytes(encoding); - result.Should().BeEquivalentTo(expectedResult); + result.ShouldBeEquivalentTo(expectedResult); } public static TheoryData GetBytes_with_Encoding_Data()