diff --git a/ArchUnitNET.xUnit/Asserts/ArchRuleAsserts.cs b/ArchUnitNET.xUnit/ArchRuleAssert.cs similarity index 85% rename from ArchUnitNET.xUnit/Asserts/ArchRuleAsserts.cs rename to ArchUnitNET.xUnit/ArchRuleAssert.cs index 8769fa318..4119f00a7 100644 --- a/ArchUnitNET.xUnit/Asserts/ArchRuleAsserts.cs +++ b/ArchUnitNET.xUnit/ArchRuleAssert.cs @@ -6,13 +6,11 @@ using ArchUnitNET.Domain; using ArchUnitNET.Fluent; -using Xunit.Sdk; - // ReSharper disable once CheckNamespace -namespace Xunit +namespace ArchUnitNET.xUnit { - partial class Assert + public static class ArchRuleAssert { /// /// Verifies that the architecture meets the criteria of the archrule. @@ -20,7 +18,7 @@ partial class Assert /// The architecture to be tested /// The rule to test the architecture with /// Thrown if the rule is violated - public static void ArchRule(Architecture architecture, IArchRule archRule) + public static void CheckRule(Architecture architecture, IArchRule archRule) { if (!archRule.HasNoViolations(architecture)) { diff --git a/ArchUnitNET.xUnit/ArchRuleExtensions.cs b/ArchUnitNET.xUnit/ArchRuleExtensions.cs index f9f8e35bd..8febf694e 100644 --- a/ArchUnitNET.xUnit/ArchRuleExtensions.cs +++ b/ArchUnitNET.xUnit/ArchRuleExtensions.cs @@ -8,7 +8,7 @@ using ArchUnitNET.Fluent; // ReSharper disable once CheckNamespace -namespace Xunit +namespace ArchUnitNET.xUnit { public static class ArchRuleExtensions { @@ -19,7 +19,7 @@ public static class ArchRuleExtensions /// The architecture to be tested public static void Check(this IArchRule archRule, Architecture architecture) { - Assert.ArchRule(architecture, archRule); + ArchRuleAssert.CheckRule(architecture, archRule); } /// @@ -29,7 +29,7 @@ public static void Check(this IArchRule archRule, Architecture architecture) /// The rule to test the architecture with public static void CheckRule(this Architecture architecture, IArchRule archRule) { - Assert.ArchRule(architecture, archRule); + ArchRuleAssert.CheckRule(architecture, archRule); } } } \ No newline at end of file diff --git a/ArchUnitNET.xUnit/ArchUnitNET.xUnit.csproj b/ArchUnitNET.xUnit/ArchUnitNET.xUnit.csproj index 8a40c4000..2d50b6ec8 100644 --- a/ArchUnitNET.xUnit/ArchUnitNET.xUnit.csproj +++ b/ArchUnitNET.xUnit/ArchUnitNET.xUnit.csproj @@ -19,13 +19,11 @@ - - - + - + diff --git a/ArchUnitNET.xUnit/Asserts/Sdk/Exceptions/FailedArchRuleException.cs b/ArchUnitNET.xUnit/FailedArchRuleException.cs similarity index 96% rename from ArchUnitNET.xUnit/Asserts/Sdk/Exceptions/FailedArchRuleException.cs rename to ArchUnitNET.xUnit/FailedArchRuleException.cs index 02c4fca35..04141c0f4 100644 --- a/ArchUnitNET.xUnit/Asserts/Sdk/Exceptions/FailedArchRuleException.cs +++ b/ArchUnitNET.xUnit/FailedArchRuleException.cs @@ -8,9 +8,10 @@ using ArchUnitNET.Domain; using ArchUnitNET.Fluent; using ArchUnitNET.Fluent.Extensions; +using Xunit.Sdk; // ReSharper disable once CheckNamespace -namespace Xunit.Sdk +namespace ArchUnitNET.xUnit { public class FailedArchRuleException : XunitException { diff --git a/ArchUnitNETTests/ArchUnitNETTests.csproj b/ArchUnitNETTests/ArchUnitNETTests.csproj index 5254a454e..ff679dc18 100644 --- a/ArchUnitNETTests/ArchUnitNETTests.csproj +++ b/ArchUnitNETTests/ArchUnitNETTests.csproj @@ -13,6 +13,7 @@ + diff --git a/ArchUnitNETTests/ArchitectureTests/ArchUnitArchitectureTests.cs b/ArchUnitNETTests/ArchitectureTests/ArchUnitArchitectureTests.cs index 6a8f3b8ac..8acc3140c 100644 --- a/ArchUnitNETTests/ArchitectureTests/ArchUnitArchitectureTests.cs +++ b/ArchUnitNETTests/ArchitectureTests/ArchUnitArchitectureTests.cs @@ -8,6 +8,7 @@ using ArchUnitNET.Domain; using ArchUnitNET.Fluent; using ArchUnitNET.Loader; +using ArchUnitNET.xUnit; using Xunit; using static ArchUnitNET.Fluent.ArchRuleDefinition; diff --git a/ArchUnitNETTests/Fluent/RuleEvaluationTests.cs b/ArchUnitNETTests/Fluent/RuleEvaluationTests.cs index 40a4ab34f..3a77f05a4 100644 --- a/ArchUnitNETTests/Fluent/RuleEvaluationTests.cs +++ b/ArchUnitNETTests/Fluent/RuleEvaluationTests.cs @@ -7,9 +7,9 @@ using ArchUnitNET.Domain; using ArchUnitNET.Fluent; using ArchUnitNET.Fluent.Extensions; +using ArchUnitNET.xUnit; using ArchUnitNETTests.Domain; using Xunit; -using Xunit.Sdk; using static System.Environment; using static ArchUnitNET.Fluent.ArchRuleDefinition; @@ -17,9 +17,11 @@ namespace ArchUnitNETTests.Fluent { public class RuleEvaluationTests { - private static readonly Architecture Architecture = StaticTestArchitectures.ArchUnitNETTestArchitecture; private const string NoClassName = "NotTheNameOfAnyClass_1592479214"; + private const string ExpectedTrueArchRuleErrorMessage = "All Evaluations passed"; + private static readonly Architecture Architecture = StaticTestArchitectures.ArchUnitNETTestArchitecture; + private static readonly IArchRule TrueArchRule1 = Classes().That().ArePrivate().Should().BePrivate(); private static readonly IArchRule TrueArchRule2 = Members().Should().Exist(); @@ -49,7 +51,13 @@ public class RuleEvaluationTests private static readonly IArchRule WrongArchRule1AndWrongArchRule3 = WrongArchRule1.And(WrongArchRule3); private static readonly IArchRule WrongArchRule4AndWrongArchRule8 = WrongArchRule4.And(WrongArchRule8); - private const string ExpectedTrueArchRuleErrorMessage = "All Evaluations passed"; + private readonly string _expectedWrongArchRule1AndWrongArchRule3ErrorMessage = + "\"Classes that are \"ArchUnitNETTests.Domain.PublicTestClass\" should be private\" failed:" + + NewLine + "\tArchUnitNETTests.Domain.PublicTestClass is public" + NewLine + + NewLine + + "\"Classes that are \"ArchUnitNETTests.Domain.PublicTestClass\" should be private and should be public or should be protected\" failed:" + + NewLine + "\tArchUnitNETTests.Domain.PublicTestClass is public" + + NewLine + NewLine; private readonly string _expectedWrongArchRule1ErrorMessage = "\"Classes that are \"ArchUnitNETTests.Domain.PublicTestClass\" should be private\" failed:" + @@ -67,6 +75,14 @@ public class RuleEvaluationTests NewLine + "\tArchUnitNETTests.Domain.PublicTestClass is public" + NewLine + NewLine; + private readonly string _expectedWrongArchRule4AndWrongArchRule8ErrorMessage = + "\"Classes that have name \"NotTheNameOfAnyClass_1592479214\" should exist\" failed:" + + NewLine + "\tThere are no objects matching the criteria" + NewLine + + NewLine + + "\"Classes that are \"ArchUnitNETTests.Domain.PublicTestClass\" should not exist or should be private\" failed:" + + NewLine + "\tArchUnitNETTests.Domain.PublicTestClass does exist and is public" + + NewLine + NewLine; + private readonly string _expectedWrongArchRule4ErrorMessage = "\"Classes that have name \"NotTheNameOfAnyClass_1592479214\" should exist\" failed:" + NewLine + "\tThere are no objects matching the criteria" + NewLine + @@ -92,47 +108,31 @@ public class RuleEvaluationTests NewLine + "\tArchUnitNETTests.Domain.PublicTestClass does exist and is public" + NewLine + NewLine; - private readonly string _expectedWrongArchRule1AndWrongArchRule3ErrorMessage = - "\"Classes that are \"ArchUnitNETTests.Domain.PublicTestClass\" should be private\" failed:" + - NewLine + "\tArchUnitNETTests.Domain.PublicTestClass is public" + NewLine + - NewLine + - "\"Classes that are \"ArchUnitNETTests.Domain.PublicTestClass\" should be private and should be public or should be protected\" failed:" + - NewLine + "\tArchUnitNETTests.Domain.PublicTestClass is public" + - NewLine + NewLine; - - private readonly string _expectedWrongArchRule4AndWrongArchRule8ErrorMessage = - "\"Classes that have name \"NotTheNameOfAnyClass_1592479214\" should exist\" failed:" + - NewLine + "\tThere are no objects matching the criteria" + NewLine + - NewLine + - "\"Classes that are \"ArchUnitNETTests.Domain.PublicTestClass\" should not exist or should be private\" failed:" + - NewLine + "\tArchUnitNETTests.Domain.PublicTestClass does exist and is public" + - NewLine + NewLine; - [Fact] public void AssertArchRuleTest() { - Assert.ArchRule(Architecture, TrueArchRule1); - Assert.ArchRule(Architecture, TrueArchRule2); + ArchRuleAssert.CheckRule(Architecture, TrueArchRule1); + ArchRuleAssert.CheckRule(Architecture, TrueArchRule2); var exception1 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule1)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule1)); var exception2 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule2)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule2)); var exception3 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule3)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule3)); var exception4 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule4)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule4)); var exception5 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule5)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule5)); var exception6 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule6)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule6)); var exception7 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule7)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule7)); var exception8 = - Assert.Throws(() => Assert.ArchRule(Architecture, WrongArchRule8)); + Assert.Throws(() => ArchRuleAssert.CheckRule(Architecture, WrongArchRule8)); var exception1And3 = Assert.Throws(() => - Assert.ArchRule(Architecture, WrongArchRule1AndWrongArchRule3)); + ArchRuleAssert.CheckRule(Architecture, WrongArchRule1AndWrongArchRule3)); var exception4And8 = Assert.Throws(() => - Assert.ArchRule(Architecture, WrongArchRule4AndWrongArchRule8)); + ArchRuleAssert.CheckRule(Architecture, WrongArchRule4AndWrongArchRule8)); Assert.Equal(_expectedWrongArchRule1ErrorMessage, exception1.Message); Assert.Equal(_expectedWrongArchRule2ErrorMessage, exception2.Message); diff --git a/ArchUnitNETTests/Fluent/Slices/SlicesTests.cs b/ArchUnitNETTests/Fluent/Slices/SlicesTests.cs index 8dc40a766..906ae1303 100644 --- a/ArchUnitNETTests/Fluent/Slices/SlicesTests.cs +++ b/ArchUnitNETTests/Fluent/Slices/SlicesTests.cs @@ -7,8 +7,8 @@ using System.Linq; using ArchUnitNET.Fluent.Slices; +using ArchUnitNET.xUnit; using Xunit; -using Xunit.Sdk; namespace ArchUnitNETTests.Fluent.Slices { diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/CustomSyntaxElementsTests.cs b/ArchUnitNETTests/Fluent/Syntax/Elements/CustomSyntaxElementsTests.cs index 0b27ab08d..0477f526a 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/CustomSyntaxElementsTests.cs +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/CustomSyntaxElementsTests.cs @@ -9,6 +9,7 @@ using ArchUnitNET.Domain; using ArchUnitNET.Domain.Extensions; using ArchUnitNET.Loader; +using ArchUnitNET.xUnit; using Xunit; using static ArchUnitNET.Fluent.ArchRuleDefinition; diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/ObjectSyntaxElementsTests.cs b/ArchUnitNETTests/Fluent/Syntax/Elements/ObjectSyntaxElementsTests.cs index 64bb1860b..6a0abed0a 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/ObjectSyntaxElementsTests.cs +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/ObjectSyntaxElementsTests.cs @@ -10,6 +10,7 @@ using ArchUnitNET.Domain; using ArchUnitNET.Domain.Extensions; using ArchUnitNET.Fluent; +using ArchUnitNET.xUnit; using ArchUnitNETTests.Domain; using Xunit; using static ArchUnitNETTests.Domain.StaticTestTypes; diff --git a/ArchUnitNETTests/StaticTestArchitectures.cs b/ArchUnitNETTests/StaticTestArchitectures.cs index 104e2ad7b..d3fc5bbf2 100644 --- a/ArchUnitNETTests/StaticTestArchitectures.cs +++ b/ArchUnitNETTests/StaticTestArchitectures.cs @@ -6,10 +6,10 @@ using ArchUnitNET.Domain; using ArchUnitNET.Loader; +using ArchUnitNET.xUnit; using ArchUnitNETTests.Domain.Dependencies.Attributes; using ArchUnitNETTests.Domain.Dependencies.Members; using TestAssembly; -using Xunit.Sdk; // ReSharper disable InconsistentNaming diff --git a/ExampleTest/ExampleArchUnitTest.cs b/ExampleTest/ExampleArchUnitTest.cs index d50d01dae..f94082a12 100644 --- a/ExampleTest/ExampleArchUnitTest.cs +++ b/ExampleTest/ExampleArchUnitTest.cs @@ -11,6 +11,7 @@ using ArchUnitNET.Domain; using ArchUnitNET.Fluent; using ArchUnitNET.Loader; +using ArchUnitNET.xUnit; using Xunit; using static ArchUnitNET.Fluent.ArchRuleDefinition; diff --git a/ExampleTest/ExampleTest.csproj b/ExampleTest/ExampleTest.csproj index 2e98c647b..2d2b2a4b4 100644 --- a/ExampleTest/ExampleTest.csproj +++ b/ExampleTest/ExampleTest.csproj @@ -12,6 +12,7 @@ +