-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathExampleArchUnitTestCooking.cs
More file actions
94 lines (76 loc) · 2.37 KB
/
ExampleArchUnitTestCooking.cs
File metadata and controls
94 lines (76 loc) · 2.37 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
82
83
84
85
86
87
88
89
90
91
92
93
94
using System.Collections.Generic;
using System.Linq;
using ArchUnitNET.Domain;
using ArchUnitNET.Domain.Extensions;
using ArchUnitNET.Loader;
using Xunit;
// ReSharper disable NotAccessedField.Local
// ReSharper disable UnusedMember.Global
namespace ExampleTest
{
public class ExampleArchUnitTestCooking
{
// initialize your test variables in the constructor
// TIP: access types of values from your architecture, then filter them using provided extension methods
public ExampleArchUnitTestCooking()
{
_chefs = ChefArchitecture.Classes.Where(cls => cls.NameEndsWith("Chef"));
_cookInterface = ChefArchitecture.GetInterfaceOfType(typeof(ICook));
}
// TIP: load your architecture once at the start to maximize performance of your tests
private static readonly Architecture ChefArchitecture = new ArchLoader()
.LoadAssembly(typeof(FrenchChef).Assembly)
.Build();
// replace <FrenchChef> with a class from your architecture
// declare variables you'll use throughout your tests up here
private readonly IEnumerable<Class> _chefs;
private readonly Interface _cookInterface;
[Fact]
public void AllChefsCook()
{
Assert.All(_chefs, chef => Assert.True(chef.ImplementsInterface(_cookInterface)));
}
}
public class FrenchChef : ICook
{
private int _age;
private string _name;
public FrenchChef(string name, int age)
{
_name = name;
_age = age;
}
public void Cook()
{
CremeBrulee();
Crepes();
Ratatouille();
}
private static void CremeBrulee() { }
private static void Crepes() { }
private static void Ratatouille() { }
}
public class ItalianChef : ICook
{
private int _age;
private string _name;
public ItalianChef(string name, int age)
{
_name = name;
_age = age;
}
public void Cook()
{
PizzaMargherita();
Tiramisu();
Lasagna();
}
private static void PizzaMargherita() { }
private static void Tiramisu() { }
private static void Lasagna() { }
}
public interface ICook
{
void Cook();
}
}