Skip to content

Commit

Permalink
refactoring : unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NeVeSpl committed Nov 19, 2023
1 parent e62885d commit 1a99cd4
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 95 deletions.
26 changes: 13 additions & 13 deletions test/NetArchTest.Rules.UnitTests/ConditionListTests.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace NetArchTest.UnitTests
{
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Rules;
using NetArchTest.TestStructure.Interfaces;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;

using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Rules;
using NetArchTest.TestStructure.Interfaces;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;

namespace NetArchTest.UnitTests
{
public class ConditionListTests
{
[Fact(DisplayName = "Conditions can be grouped together using 'or' logic.")]
Expand Down Expand Up @@ -165,4 +165,4 @@ public void GetResult_Success_ReturnEmptyFailedTypes()
Assert.Empty(result.FailingTypes);
}
}
}
}
31 changes: 15 additions & 16 deletions test/NetArchTest.Rules.UnitTests/ConditionTests.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
using NetArchTest.TestStructure.Classes;
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Rules;
using NetArchTest.TestStructure.Classes;
using NetArchTest.TestStructure.CustomAttributes;
using NetArchTest.TestStructure.Dependencies.Examples;
using NetArchTest.TestStructure.Dependencies.Implementation;
using NetArchTest.TestStructure.Inheritance;
using NetArchTest.TestStructure.Interfaces;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.Nested;
using NetArchTest.UnitTests.TestDoubles;
using Xunit;
using static NetArchTest.TestStructure.Nested.NestedPublic;

namespace NetArchTest.UnitTests
{
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Rules;
using NetArchTest.TestStructure.CustomAttributes;
using NetArchTest.TestStructure.Dependencies.Examples;
using NetArchTest.TestStructure.Dependencies.Implementation;
using NetArchTest.TestStructure.Inheritance;
using NetArchTest.TestStructure.Interfaces;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.Nested;
using NetArchTest.UnitTests.TestDoubles;
using Xunit;
using static NetArchTest.TestStructure.Nested.NestedPublic;

public class ConditionTests
{
[Fact(DisplayName = "Types can be selected by name.")]
Expand Down
24 changes: 12 additions & 12 deletions test/NetArchTest.Rules.UnitTests/FunctionSequenceTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace NetArchTest.UnitTests
{
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Functions;
using NetArchTest.TestStructure.Abstract;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;
using NetArchTest.Rules;
using Mono.Cecil;
using NetArchTest.RuleEngine;
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Functions;
using NetArchTest.TestStructure.Abstract;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;
using NetArchTest.Rules;
using Mono.Cecil;
using NetArchTest.RuleEngine;

namespace NetArchTest.UnitTests
{
public class FunctionSequenceTests
{
[Fact(DisplayName = "Setting the Selected flag to false will return the types that fail the sequence.")]
Expand Down
22 changes: 11 additions & 11 deletions test/NetArchTest.Rules.UnitTests/PolicyDefinitionTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace NetArchTest.UnitTests
{
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Policies;
using NetArchTest.Rules;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;

using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Policies;
using NetArchTest.Rules;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;

namespace NetArchTest.UnitTests
{
public class PolicyDefinitionTests
{
private const string POLICY_NAME = "Name";
Expand Down
25 changes: 12 additions & 13 deletions test/NetArchTest.Rules.UnitTests/PredicateListTests.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace NetArchTest.UnitTests
{
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Rules;
using NetArchTest.TestStructure.Generic;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.Rules;
using NetArchTest.TestStructure.Generic;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using Xunit;

namespace NetArchTest.UnitTests
{
public class PredicateListTests
{
[Fact(DisplayName = "Predicates can be grouped together using 'or' logic.")]
Expand Down Expand Up @@ -76,6 +76,5 @@ public void Or_MultipleInstances_TreatedAsSeparateGroups()
Assert.Contains<Type>(typeof(ClassA2), result);
Assert.Contains<Type>(typeof(ClassB2), result);
}

}
}
}
57 changes: 27 additions & 30 deletions test/NetArchTest.Rules.UnitTests/PredicateTests.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
using NetArchTest.TestStructure.NameMatching.Namespace3.A;
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.CrossAssemblyTest.A;
using NetArchTest.CrossAssemblyTest.B;
using NetArchTest.Rules;
using NetArchTest.TestStructure.Abstract;
using NetArchTest.TestStructure.Classes;
using NetArchTest.TestStructure.CustomAttributes;
using NetArchTest.TestStructure.Dependencies.Examples;
using NetArchTest.TestStructure.Dependencies.Implementation;
using NetArchTest.TestStructure.Generic;
using NetArchTest.TestStructure.Inheritance;
using NetArchTest.TestStructure.Interfaces;
using NetArchTest.TestStructure.Mutability;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using NetArchTest.TestStructure.NameMatching.Namespace3.A;
using NetArchTest.TestStructure.NameMatching.Namespace3.B;
using NetArchTest.TestStructure.NamespaceMatching.Namespace1;
using NetArchTest.TestStructure.NamespaceMatching.NamespaceA;
using NetArchTest.TestStructure.Nested;
using NetArchTest.TestStructure.Nullable;
using NetArchTest.TestStructure.Scope;
using NetArchTest.TestStructure.Sealed;
using NetArchTest.UnitTests.TestDoubles;
using Xunit;

namespace NetArchTest.UnitTests
{
using System;
using System.Linq;
using System.Reflection;
using NetArchTest.CrossAssemblyTest.A;
using NetArchTest.CrossAssemblyTest.B;
using NetArchTest.TestStructure.Abstract;
using NetArchTest.TestStructure.Classes;
using NetArchTest.TestStructure.CustomAttributes;
using NetArchTest.TestStructure.Dependencies;
using NetArchTest.TestStructure.Dependencies.Implementation;
using NetArchTest.TestStructure.Generic;
using NetArchTest.TestStructure.Inheritance;
using NetArchTest.TestStructure.Interfaces;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
using NetArchTest.TestStructure.NameMatching.Namespace3;
using NetArchTest.TestStructure.NamespaceMatching.Namespace1;
using NetArchTest.TestStructure.NamespaceMatching.NamespaceA;
using NetArchTest.TestStructure.Nested;
using NetArchTest.TestStructure.Scope;
using NetArchTest.TestStructure.Sealed;
using NetArchTest.TestStructure.Mutability;
using Xunit;
using NetArchTest.TestStructure.Nullable;
using NetArchTest.TestStructure.Dependencies.Examples;
using NetArchTest.Rules;
using NetArchTest.UnitTests.TestDoubles;

public class PredicateTests
{
[Fact(DisplayName = "Types can be selected by name name.")]
Expand Down
3 changes: 3 additions & 0 deletions test/NetArchTest.Rules.UnitTests/TypesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ public void InCurrentDomain_SystemTypesExcluded()
Assert.DoesNotContain(result, t => t.FullName.StartsWith("Microsoft.") || t.FullName.Equals("Microsoft"));
Assert.DoesNotContain(result, t => t.FullName.StartsWith("netstandard.") | t.FullName.Equals("netstandard"));
}

[Fact(DisplayName = "Types that reside in namespace that has \"System\" prefix but is not system namespace should be included in the current domain. ")]
public void InCurrentDomain_TypesWithPrefixSystemInclude()
{
var result = Types.InCurrentDomain().GetTypes();

Assert.Contains(result, t => t.FullName == typeof(SystemAsNamespacePrefix.ExampleClass).FullName);
}

[Fact(DisplayName = "Types that reside in namespace that has \"Module\" prefix but is not <Module> namespace should be included in the current domain. ")]
public void InCurrentDomain_TypesWithPrefixModuleInclude()
{
var result = Types.InCurrentDomain().GetTypes();

Assert.Contains(result, t => t.FullName == typeof(ModuleAsNamespacePrefix.ExampleClass).FullName);
}

[Fact(DisplayName = "<Module> types should be excluded from the current domain.")]
public void InCurrentDomain_SystemTypesExcludedModule()
{
Expand Down

0 comments on commit 1a99cd4

Please sign in to comment.