-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from brandhuf/fix-complex-conditions
Fix complex conditions
- Loading branch information
Showing
12 changed files
with
186 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
ArchUnitNETTests/Fluent/Syntax/DependenciesToOtherAssembliesTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright 2019 Florian Gather <[email protected]> | ||
// Copyright 2019 Fritz Brandhuber <[email protected]> | ||
// Copyright 2020 Pavel Fischer <[email protected]> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
using ArchUnitNET.Domain; | ||
using ArchUnitNET.Domain.Extensions; | ||
using ArchUnitNET.Loader; | ||
using ArchUnitNET.xUnit; | ||
using TestAssembly.DependencyTargets; | ||
using Xunit; | ||
using static ArchUnitNET.Fluent.ArchRuleDefinition; | ||
|
||
namespace ArchUnitNETTests.Fluent.Syntax | ||
{ | ||
public class DependenciesToOtherAssembliesTests | ||
{ | ||
public class TestDependencyIssue | ||
{ | ||
private static readonly Architecture Architecture = | ||
new ArchLoader().LoadAssemblies(typeof(DependenciesToOtherAssembliesTests).Assembly).Build(); | ||
|
||
[Fact] | ||
public void DependOnAnyTypesThatTest() | ||
{ | ||
Types().That().Are(typeof(DependingClass)).Should() | ||
.DependOnAnyTypesThat().Are(typeof(ClassInTestAssembly)).Check(Architecture); | ||
Assert.Throws<FailedArchRuleException>(() => Types().That().Are(typeof(DependingClass)).Should() | ||
.NotDependOnAnyTypesThat().Are(typeof(ClassInTestAssembly)).Check(Architecture)); | ||
} | ||
|
||
[Fact] | ||
public void BeAssignableToTypesThatTest() | ||
{ | ||
Types().That().Are(typeof(DependingClass)).Should() | ||
.BeAssignableToTypesThat().Are(typeof(IInterfaceInTestAssembly)).Check(Architecture); | ||
Assert.Throws<FailedArchRuleException>(() => Types().That().Are(typeof(DependingClass)).Should() | ||
.NotBeAssignableToTypesThat().Are(typeof(IInterfaceInTestAssembly)).Check(Architecture)); | ||
} | ||
|
||
[Fact] | ||
public void OnlyDependOnTypesThatTest() | ||
{ | ||
Types().That().Are(typeof(DependingClass)).Should() | ||
.OnlyDependOnTypesThat().Are(typeof(object), typeof(AttributeInTestAssembly), | ||
typeof(IInterfaceInTestAssembly), typeof(ClassInTestAssembly), typeof(DependingClass)) | ||
.Check(Architecture); | ||
} | ||
|
||
[Fact] | ||
public void HaveAnyAttributesThatTest() | ||
{ | ||
Types().That().Are(typeof(DependingClass)).Should() | ||
.HaveAnyAttributesThat().Are(typeof(AttributeInTestAssembly)).Check(Architecture); | ||
Assert.Throws<FailedArchRuleException>(() => Types().That().Are(typeof(DependingClass)).Should() | ||
.NotHaveAnyAttributesThat().Are(typeof(AttributeInTestAssembly)).Check(Architecture)); | ||
} | ||
|
||
[Fact] | ||
public void OnlyHaveAttributesThatTest() | ||
{ | ||
Types().That().Are(typeof(DependingClass)).Should() | ||
.OnlyHaveAttributesThat().Are(typeof(AttributeInTestAssembly)).Check(Architecture); | ||
} | ||
|
||
[Fact] | ||
public void IncludeReferencedTypesTest() | ||
{ | ||
var classInTestAssembly = Architecture.GetClassOfType(typeof(ClassInTestAssembly)); | ||
Assert.Contains(classInTestAssembly, Types(true).GetObjects(Architecture)); | ||
Assert.Contains(classInTestAssembly, Classes(true).GetObjects(Architecture)); | ||
|
||
var attributeInTestAssembly = Architecture.GetAttributeOfType(typeof(AttributeInTestAssembly)); | ||
Assert.Contains(attributeInTestAssembly, Types(true).GetObjects(Architecture)); | ||
Assert.Contains(attributeInTestAssembly, Attributes(true).GetObjects(Architecture)); | ||
|
||
var interfaceInTestAssembly = Architecture.GetInterfaceOfType(typeof(IInterfaceInTestAssembly)); | ||
Assert.Contains(interfaceInTestAssembly, Types(true).GetObjects(Architecture)); | ||
Assert.Contains(interfaceInTestAssembly, Interfaces(true).GetObjects(Architecture)); | ||
} | ||
} | ||
} | ||
|
||
[AttributeInTestAssembly] | ||
public class DependingClass : IInterfaceInTestAssembly | ||
{ | ||
private ClassInTestAssembly dep; | ||
|
||
public DependingClass() | ||
{ | ||
dep = new ClassInTestAssembly(); | ||
dep.MethodInTestAssembly(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2019 Florian Gather <[email protected]> | ||
// Copyright 2019 Fritz Brandhuber <[email protected]> | ||
// Copyright 2020 Pavel Fischer <[email protected]> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
using System; | ||
|
||
namespace TestAssembly.DependencyTargets | ||
{ | ||
public class AttributeInTestAssembly : Attribute | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2019 Florian Gather <[email protected]> | ||
// Copyright 2019 Fritz Brandhuber <[email protected]> | ||
// Copyright 2020 Pavel Fischer <[email protected]> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
namespace TestAssembly.DependencyTargets | ||
{ | ||
public class ClassInTestAssembly | ||
{ | ||
public void MethodInTestAssembly(){} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
TestAssembly/DependencyTargets/IInterfaceInTestAssembly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2019 Florian Gather <[email protected]> | ||
// Copyright 2019 Fritz Brandhuber <[email protected]> | ||
// Copyright 2020 Pavel Fischer <[email protected]> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
namespace TestAssembly.DependencyTargets | ||
{ | ||
public interface IInterfaceInTestAssembly | ||
{ | ||
} | ||
} |
Oops, something went wrong.