diff --git a/src/core-taggeds-failure/Failure.Tests/AssertHelper/AssertHelper.cs b/src/core-taggeds-failure/Failure.Tests/AssertHelper/AssertHelper.cs index c9e8a525..3577af48 100644 --- a/src/core-taggeds-failure/Failure.Tests/AssertHelper/AssertHelper.cs +++ b/src/core-taggeds-failure/Failure.Tests/AssertHelper/AssertHelper.cs @@ -1,17 +1,16 @@ using System; -using Xunit; - -namespace PrimeFuncPack.Core.Tests; - -internal static class AssertHelper -{ - public static void AssertEqualFailures( - (TFailureCode FailureCode, string FailureMessage, Exception? SourceException) expected, - (TFailureCode FailureCode, string FailureMessage, Exception? SourceException) actual) - where TFailureCode : struct - { - Assert.StrictEqual(expected.FailureCode, actual.FailureCode); - Assert.Equal(expected.FailureMessage, actual.FailureMessage); - Assert.Equal(expected.SourceException, actual.SourceException); - } -} + +namespace PrimeFuncPack.Core.Tests; + +internal static class AssertHelper +{ + internal static void AssertEqualFailures( + (TFailureCode FailureCode, string FailureMessage, Exception? SourceException) expected, + (TFailureCode FailureCode, string FailureMessage, Exception? SourceException) actual) + where TFailureCode : struct + { + Assert.StrictEqual(expected.FailureCode, actual.FailureCode); + Assert.Equal(expected.FailureMessage, actual.FailureMessage); + Assert.Same(expected.SourceException, actual.SourceException); + } +} diff --git a/src/core-taggeds-failure/Failure.Tests/GlobalUsings.cs b/src/core-taggeds-failure/Failure.Tests/GlobalUsings.cs new file mode 100644 index 00000000..8c927eb7 --- /dev/null +++ b/src/core-taggeds-failure/Failure.Tests/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/src/core-taggeds-failure/Failure.Tests/Source/FailureTestSource.cs b/src/core-taggeds-failure/Failure.Tests/Source/FailureTestSource.cs index 51c47bff..fbe260f8 100644 --- a/src/core-taggeds-failure/Failure.Tests/Source/FailureTestSource.cs +++ b/src/core-taggeds-failure/Failure.Tests/Source/FailureTestSource.cs @@ -6,10 +6,6 @@ internal static partial class FailureTestSource { private sealed class SomeException : Exception { - public static readonly SomeException SomeInstance; - - static SomeException() - => - SomeInstance = new(); + internal static SomeException Instance { get; } = new(); } } \ No newline at end of file diff --git a/src/core-taggeds-failure/Failure.Tests/Source/Source.Equal.cs b/src/core-taggeds-failure/Failure.Tests/Source/Source.Equal.cs index 431f9993..b57b9742 100644 --- a/src/core-taggeds-failure/Failure.Tests/Source/Source.Equal.cs +++ b/src/core-taggeds-failure/Failure.Tests/Source/Source.Equal.cs @@ -1,78 +1,67 @@ using System; -using System.Collections.Generic; using PrimeFuncPack.UnitTest; namespace PrimeFuncPack.Core.Tests; partial class FailureTestSource { - public static IEnumerable EqualPairTestData + public static TheoryData, Failure> EqualPairTestData => - new[] + new() { - new object[] { new Failure(), - default(Failure) + default }, - new object[] { new Failure(), new Failure(default, null) }, - new object[] { - default(Failure), + default, new Failure(default, string.Empty) { SourceException = null } }, - new object[] { new Failure(default, null), new Failure() }, - new object[] { new Failure(default, string.Empty), - default(Failure) + default }, - new object[] { new Failure(EnumType.One, null) { - SourceException = SomeException.SomeInstance + SourceException = SomeException.Instance }, new Failure(EnumType.One, null) { - SourceException = SomeException.SomeInstance + SourceException = SomeException.Instance } }, - new object[] { new Failure(EnumType.Two, string.Empty), new Failure(EnumType.Two, null) }, - new object[] { new Failure(EnumType.Three, null), new Failure(EnumType.Three, string.Empty) }, - new object[] { new Failure(EnumType.Zero, string.Empty), new Failure(EnumType.Zero, string.Empty) }, - new object[] { new Failure(EnumType.One, TestData.SomeString) { - SourceException = SomeException.SomeInstance + SourceException = SomeException.Instance }, new Failure(EnumType.One, TestData.SomeString) { - SourceException = SomeException.SomeInstance + SourceException = SomeException.Instance } } }; diff --git a/src/core-taggeds-failure/Failure.Tests/Source/Source.ToException.cs b/src/core-taggeds-failure/Failure.Tests/Source/Source.ToException.cs index 506fd098..932be39f 100644 --- a/src/core-taggeds-failure/Failure.Tests/Source/Source.ToException.cs +++ b/src/core-taggeds-failure/Failure.Tests/Source/Source.ToException.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Reflection; using PrimeFuncPack.UnitTest; @@ -7,36 +6,30 @@ namespace PrimeFuncPack.Core.Tests; partial class FailureTestSource { - public static IEnumerable ToExceptionTestData + public static TheoryData, Failure.Exception> ToExceptionTestData => - new[] + new() { - new object[] { - default(Failure), + default, InnerCreate(default(EnumType), null, null) }, - new object[] { new Failure(EnumType.One, null), InnerCreate(EnumType.One, null, null) }, - new object[] { new Failure(EnumType.Two, string.Empty), InnerCreate(EnumType.Two, null, null) }, - new object[] { new Failure(EnumType.Zero, TestData.WhiteSpaceString), InnerCreate(EnumType.Zero, TestData.WhiteSpaceString, null) }, - new object[] { new Failure(EnumType.Two, TestData.SomeString), InnerCreate(EnumType.Two, TestData.SomeString, null) }, - new object[] { new Failure(EnumType.Three, null) { @@ -44,7 +37,6 @@ public static IEnumerable ToExceptionTestData }, InnerCreate(EnumType.Three, null, new InvalidOperationException("Some error message")) }, - new object[] { new Failure(EnumType.One, string.Empty) { @@ -52,7 +44,6 @@ public static IEnumerable ToExceptionTestData }, InnerCreate(EnumType.One, null, new("Some Exception")) }, - new object[] { new Failure(EnumType.One, TestData.MixedWhiteSpacesString) { @@ -60,7 +51,6 @@ public static IEnumerable ToExceptionTestData }, InnerCreate(EnumType.One, TestData.MixedWhiteSpacesString, new("Some Exception")) }, - new object[] { new Failure(EnumType.Two, TestData.AnotherString) { @@ -78,9 +68,9 @@ private static Failure.Exception InnerCreate( var constructor = typeof(Failure.Exception).GetConstructor( bindingAttr: BindingFlags.NonPublic | BindingFlags.Instance, - types: new[] { typeof(TFailureCode), typeof(string), typeof(Exception) }) + types: [typeof(TFailureCode), typeof(string), typeof(Exception)]) ?? throw new InvalidOperationException($"Required constructor in type {type} was not found"); - return (Failure.Exception)constructor.Invoke(new object?[] { failureCode, message, innerException }); + return (Failure.Exception)constructor.Invoke([failureCode, message, innerException]); } } \ No newline at end of file diff --git a/src/core-taggeds-failure/Failure.Tests/Source/Source.Unequal.cs b/src/core-taggeds-failure/Failure.Tests/Source/Source.Unequal.cs index 082123ab..6c876f31 100644 --- a/src/core-taggeds-failure/Failure.Tests/Source/Source.Unequal.cs +++ b/src/core-taggeds-failure/Failure.Tests/Source/Source.Unequal.cs @@ -1,52 +1,44 @@ using System; -using System.Collections.Generic; using PrimeFuncPack.UnitTest; namespace PrimeFuncPack.Core.Tests; partial class FailureTestSource { - public static IEnumerable UnequalPairTestData + public static TheoryData, Failure> UnequalPairTestData => - new[] + new() { - new object[] { new Failure(), new Failure(EnumType.One, null) }, - new object[] { - default(Failure), + default, new Failure(EnumType.Two, TestData.WhiteSpaceString) }, - new object[] { new Failure(EnumType.Three, null), - default(Failure) + default }, - new object[] { new Failure(EnumType.One, TestData.TabString), new Failure() }, - new object[] { new Failure(EnumType.One, TestData.SomeString), new Failure(EnumType.Two, TestData.SomeString) }, - new object[] { new Failure(EnumType.One, TestData.SomeString) { - SourceException = SomeException.SomeInstance + SourceException = SomeException.Instance }, new Failure(EnumType.One, TestData.UpperSomeString) { - SourceException = SomeException.SomeInstance + SourceException = SomeException.Instance } }, - new object[] { new Failure(EnumType.One, TestData.SomeString) { diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.Exception.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.Exception.cs index 57ac2b7c..e2470343 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.Exception.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.Exception.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.cs index b08df5b2..e33523f3 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Deconstruct.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Equality.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Equality.cs index f9f3828a..25b926f9 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Equality.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Equality.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Inequality.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Inequality.cs index b1527683..a022df8c 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Inequality.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Inequality.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Object.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Object.cs index 82b16e66..0f698dbc 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Object.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Object.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Other.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Other.cs index 4af1893a..95900d8f 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Other.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Other.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Static.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Static.cs index 3c3ad653..f5dbf225 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Static.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Equals.Static.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Exception.To.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Exception.To.cs index 13762db1..13ebd068 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Exception.To.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Exception.To.cs @@ -1,7 +1,6 @@ using System; using DeepEqual.Syntax; using PrimeFuncPack.UnitTest; -using Xunit; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Factory.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Factory.cs index 301cf916..9335516d 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Factory.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.Factory.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.Map.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.Map.cs index aef7b883..9fe0a9b8 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.Map.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.Map.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.With.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.With.cs index f46087ad..f2415a8d 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.With.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.FailureCode.With.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.GetHashCode.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.GetHashCode.cs index c45d650f..0b4660fc 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.GetHashCode.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.GetHashCode.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.UnitTest.TestData; namespace PrimeFuncPack.Core.Tests; @@ -15,7 +14,7 @@ public static void GetHashCode_FirstIsEqualToSecondAndTypesAreSame_ExpectHashCod var firstHashCode = first.GetHashCode(); var secondHashCode = second.GetHashCode(); - Assert.Equal(firstHashCode, secondHashCode); + Assert.StrictEqual(firstHashCode, secondHashCode); } [Fact] @@ -27,7 +26,7 @@ public static void GetHashCode_FirstTypeIsNotEqualToSecondType_ExpectHashCodesAr var firstHashCode = first.GetHashCode(); var secondHashCode = second.GetHashCode(); - Assert.NotEqual(firstHashCode, secondHashCode); + Assert.NotStrictEqual(firstHashCode, secondHashCode); } [Theory] @@ -38,6 +37,6 @@ public static void GetHashCode_FirstIsNotEqualToSecondAndTypesAreSame_ExpectHash var firstHashCode = first.GetHashCode(); var secondHashCode = second.GetHashCode(); - Assert.NotEqual(firstHashCode, secondHashCode); + Assert.NotStrictEqual(firstHashCode, secondHashCode); } } diff --git a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.ToString.cs b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.ToString.cs index c5ec7cee..f189db0c 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.ToString.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.Failure/Test.ToString.cs @@ -1,7 +1,6 @@ using System; using System.Globalization; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.UnitTest.TestData; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.Unit.cs b/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.Unit.cs index 7c757558..fe07a481 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.Unit.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.Unit.cs @@ -1,5 +1,4 @@ using System; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.cs b/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.cs index 7539695a..83dd818c 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.FailureExtensions/Test.ToFailure.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Equals.cs b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Equals.cs index 50735040..42eb5d73 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Equals.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Equals.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; namespace PrimeFuncPack.Core.Tests; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Exception.cs b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Exception.cs index 6e172ad2..352b980e 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Exception.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Exception.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.Exception.cs b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.Exception.cs index a6141080..eabd3eab 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.Exception.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.Exception.cs @@ -1,5 +1,4 @@ using System; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.cs b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.cs index e3fc81d6..2da36f28 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.Unit.cs @@ -1,5 +1,4 @@ using System; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData; diff --git a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.cs b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.cs index 1107e62b..54bf3230 100644 --- a/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.cs +++ b/src/core-taggeds-failure/Failure.Tests/Test.FailureStatic/FailureStaticTest.Factory.cs @@ -1,6 +1,5 @@ using System; using PrimeFuncPack.UnitTest; -using Xunit; using static PrimeFuncPack.Core.Tests.AssertHelper; using static PrimeFuncPack.UnitTest.TestData;