forked from TNG/ArchUnitNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebsiteDocumentationTest.cs
More file actions
81 lines (71 loc) · 2.66 KB
/
WebsiteDocumentationTest.cs
File metadata and controls
81 lines (71 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2019 Florian Gather <florian.gather@tngtech.com>
// Copyright 2019 Fritz Brandhuber <fritz.brandhuber@tngtech.com>
// Copyright 2020 Pavel Fischer <rubbiroid@gmail.com>
//
// SPDX-License-Identifier: Apache-2.0
//
// ReSharper disable InconsistentNaming
// ReSharper disable SuggestVarOrType_SimpleTypes
using ArchUnitNET.Domain;
using ArchUnitNET.Fluent;
using ArchUnitNET.Loader;
using Model;
using View;
using Xunit;
using static ArchUnitNET.Fluent.ArchRuleDefinition;
using static ArchUnitNET.Fluent.Slices.SliceRuleDefinition;
namespace ExampleTest
{
public class WebsiteDocumentationTest
{
private static readonly Architecture Architecture = new ArchLoader()
.LoadAssembly(typeof(WebsiteDocumentationTest).Assembly).Build();
[Fact]
public void NamespaceDependency()
{
IArchRule rule = Types().That().ResideInNamespace("Model").Should()
.NotDependOnAny(Types().That().ResideInNamespace("Controller"));
Assert.False(rule.HasNoViolations(Architecture));
//rule.Check(Architecture);
}
[Fact]
public void ClassDependency()
{
IArchRule rule = Classes().That().AreAssignableTo(typeof(ICar)).Should()
.NotDependOnAny(Classes().That().AreAssignableTo(typeof(ICanvas)));
Assert.False(rule.HasNoViolations(Architecture));
//rule.Check(Architecture);
}
[Fact]
public void InheritanceNaming()
{
IArchRule rule = Classes().That().AreAssignableTo(typeof(ICar)).Should()
.HaveNameContaining("Car");
Assert.False(rule.HasNoViolations(Architecture));
//rule.Check(Architecture);
}
[Fact]
public void ClassNamespaceContainment()
{
IArchRule rule = Classes().That().HaveNameContaining("Canvas").Should()
.ResideInNamespace(typeof(ICanvas).Namespace);
Assert.False(rule.HasNoViolations(Architecture));
//rule.Check(Architecture);
}
[Fact]
public void AttributeAccess()
{
IArchRule rule = Classes().That().DoNotHaveAnyAttributes(typeof(Display)).Should()
.NotDependOnAny(Classes().That().AreAssignableTo(typeof(ICanvas)));
Assert.False(rule.HasNoViolations(Architecture));
//rule.Check(Architecture);
}
[Fact]
public void Cycles()
{
IArchRule rule = Slices().Matching("Module.(*)").Should().BeFreeOfCycles();
Assert.False(rule.HasNoViolations(Architecture));
//rule.Check(Architecture);
}
}
}