forked from TNG/ArchUnitNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleArchUnitTestCooking.cs
More file actions
111 lines (92 loc) · 2.67 KB
/
ExampleArchUnitTestCooking.cs
File metadata and controls
111 lines (92 loc) · 2.67 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright 2019 Florian Gather <florian.gather@tngtech.com>
// Copyright 2019 Paula Ruiz <paularuiz22@gmail.com>
// Copyright 2019 Fritz Brandhuber <fritz.brandhuber@tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
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();
}
}