Skip to content

Commit c767974

Browse files
Merge branch 'main' into single-fluent-interface-implementation
2 parents bcc8a02 + 92ae901 commit c767974

38 files changed

Lines changed: 415 additions & 49 deletions

File tree

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
$major = $matches[1]
151151
$minor = $matches[2]
152152
$packageVersion = "$env:GITHUB_REF_NAME"
153-
$assemblyVersion = "$major.$minor.$env:GITHUB_RUN_NUMBER.0"
153+
$assemblyVersion = "$major.$minor.0.0"
154154
Write-Host "Package version: $packageVersion"
155155
Write-Host "Assembly version: $assemblyVersion"
156156
dotnet pack -c Release --output nupkgs -p:PackageVersion=$packageVersion -p:AssemblyVersion=$assemblyVersion

ArchUnit.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceAssembly", "TestAs
4848
EndProject
4949
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilteredDirectoryUnavailableTypesAssembly", "TestAssemblies\FilteredDirectoryUnavailableTypesAssembly\FilteredDirectoryUnavailableTypesAssembly.csproj", "{AA695589-8CCC-4474-9A7F-01A6376C375A}"
5050
EndProject
51+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchUnitNET.MSTestV3Tests", "ArchUnitNET.MSTestV3Tests\ArchUnitNET.MSTestV3Tests.csproj", "{F9856A37-C0E0-453C-888F-D794856D3404}"
52+
EndProject
53+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchUnitNET.MSTestV4Tests", "ArchUnitNET.MSTestV4Tests\ArchUnitNET.MSTestV4Tests.csproj", "{9858F5A1-356B-4CF0-8E50-62F2E881CC36}"
54+
EndProject
55+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchUnitNET.MSTestV4", "ArchUnitNET.MSTestV4\ArchUnitNET.MSTestV4.csproj", "{50F0F64A-F4A2-47E5-82E9-B66F07CE4198}"
56+
EndProject
5157
Global
5258
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5359
Debug|Any CPU = Debug|Any CPU
@@ -142,6 +148,18 @@ Global
142148
{AA695589-8CCC-4474-9A7F-01A6376C375A}.Debug|Any CPU.Build.0 = Debug|Any CPU
143149
{AA695589-8CCC-4474-9A7F-01A6376C375A}.Release|Any CPU.ActiveCfg = Release|Any CPU
144150
{AA695589-8CCC-4474-9A7F-01A6376C375A}.Release|Any CPU.Build.0 = Release|Any CPU
151+
{F9856A37-C0E0-453C-888F-D794856D3404}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
152+
{F9856A37-C0E0-453C-888F-D794856D3404}.Debug|Any CPU.Build.0 = Debug|Any CPU
153+
{F9856A37-C0E0-453C-888F-D794856D3404}.Release|Any CPU.ActiveCfg = Release|Any CPU
154+
{F9856A37-C0E0-453C-888F-D794856D3404}.Release|Any CPU.Build.0 = Release|Any CPU
155+
{9858F5A1-356B-4CF0-8E50-62F2E881CC36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
156+
{9858F5A1-356B-4CF0-8E50-62F2E881CC36}.Debug|Any CPU.Build.0 = Debug|Any CPU
157+
{9858F5A1-356B-4CF0-8E50-62F2E881CC36}.Release|Any CPU.ActiveCfg = Release|Any CPU
158+
{9858F5A1-356B-4CF0-8E50-62F2E881CC36}.Release|Any CPU.Build.0 = Release|Any CPU
159+
{50F0F64A-F4A2-47E5-82E9-B66F07CE4198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
160+
{50F0F64A-F4A2-47E5-82E9-B66F07CE4198}.Debug|Any CPU.Build.0 = Debug|Any CPU
161+
{50F0F64A-F4A2-47E5-82E9-B66F07CE4198}.Release|Any CPU.ActiveCfg = Release|Any CPU
162+
{50F0F64A-F4A2-47E5-82E9-B66F07CE4198}.Release|Any CPU.Build.0 = Release|Any CPU
145163
EndGlobalSection
146164
GlobalSection(SolutionProperties) = preSolution
147165
HideSolutionNode = FALSE

ArchUnitNET.MSTestV2/ArchUnitNET.MSTestV2.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
44
<IsPackable>true</IsPackable>
55
<Title>ArchUnit C# MSTestV2 Extension</Title>
6-
<Description>MSTestV2 Extension for the C# Version of ArchUnit (see: archunit.org)</Description>
6+
<Description>MSTestV2 Extension (compatible with MSTestV3) for the C# Version of ArchUnit (see: archunit.org)</Description>
77
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
88
<RepositoryUrl>https://github.com/TNG/ArchUnitNET</RepositoryUrl>
99
<PackageTags>test;arch;archunit;mstest;mstestv2</PackageTags>
@@ -15,9 +15,11 @@
1515
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
1717
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
18+
<SignAssembly>True</SignAssembly>
19+
<AssemblyOriginatorKeyFile>..\strongNameKey.snk</AssemblyOriginatorKeyFile>
20+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
1821
</PropertyGroup>
1922
<ItemGroup>
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
2123
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
2224
</ItemGroup>
2325
<ItemGroup>

ArchUnitNET.MSTestV2Tests/ArchUnitNET.MSTestV2Tests.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
<IsPackable>false</IsPackable>
55
<Company>TNG Technology Consulting GmbH</Company>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7+
<SignAssembly>True</SignAssembly>
8+
<AssemblyOriginatorKeyFile>..\strongNameKey.snk</AssemblyOriginatorKeyFile>
9+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
710
</PropertyGroup>
811
<ItemGroup>
912
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
10-
<PackageReference Include="MSTest.TestAdapter" Version="3.10.4" />
11-
<PackageReference Include="MSTest.TestFramework" Version="3.10.4" />
13+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
14+
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
1215
</ItemGroup>
1316
<ItemGroup>
1417
<ProjectReference Include="..\ArchUnitNET.MSTestV2\ArchUnitNET.MSTestV2.csproj" />

ArchUnitNET.MSTestV2Tests/RuleEvaluationTests.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ public static void Setup(TestContext context)
3131
public void ArchRuleAssertTest()
3232
{
3333
ArchRuleAssert.FulfilsRule(_architecture, _trueRule);
34-
Assert.ThrowsExactly<AssertFailedException>(() =>
34+
Assert.ThrowsException<AssertFailedException>(() =>
3535
ArchRuleAssert.FulfilsRule(_architecture, _falseRule)
3636
);
3737
Assert.AreEqual(
3838
_expectedErrorMessage,
3939
RemoveAssertionText(
4040
Assert
41-
.ThrowsExactly<AssertFailedException>(() =>
41+
.ThrowsException<AssertFailedException>(() =>
4242
ArchRuleAssert.FulfilsRule(_architecture, _falseRule)
4343
)
4444
.Message
@@ -51,13 +51,15 @@ public void ArchRuleExtensionsTest()
5151
{
5252
_architecture.CheckRule(_trueRule);
5353
_trueRule.Check(_architecture);
54-
Assert.ThrowsExactly<AssertFailedException>(() => _architecture.CheckRule(_falseRule));
55-
Assert.ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture));
54+
Assert.ThrowsException<AssertFailedException>(() =>
55+
_architecture.CheckRule(_falseRule)
56+
);
57+
Assert.ThrowsException<AssertFailedException>(() => _falseRule.Check(_architecture));
5658
Assert.AreEqual(
5759
_expectedErrorMessage,
5860
RemoveAssertionText(
5961
Assert
60-
.ThrowsExactly<AssertFailedException>(() =>
62+
.ThrowsException<AssertFailedException>(() =>
6163
_architecture.CheckRule(_falseRule)
6264
)
6365
.Message
@@ -67,7 +69,9 @@ public void ArchRuleExtensionsTest()
6769
_expectedErrorMessage,
6870
RemoveAssertionText(
6971
Assert
70-
.ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture))
72+
.ThrowsException<AssertFailedException>(() =>
73+
_falseRule.Check(_architecture)
74+
)
7175
.Message
7276
)
7377
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<IsPackable>false</IsPackable>
5+
<Company>TNG Technology Consulting GmbH</Company>
6+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="MSTest" Version="3.10.4" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<ProjectReference Include="..\ArchUnitNET.MSTestV2\ArchUnitNET.MSTestV2.csproj" />
16+
</ItemGroup>
17+
</Project>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using ArchUnitNET.Domain;
2+
using ArchUnitNET.Fluent;
3+
using ArchUnitNET.Fluent.Extensions;
4+
using ArchUnitNET.Loader;
5+
using ArchUnitNET.MSTestV2;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using static ArchUnitNET.Fluent.ArchRuleDefinition;
8+
9+
namespace ArchUnitNET.MSTestV3Tests
10+
{
11+
[TestClass]
12+
public class RuleEvaluationTests
13+
{
14+
private static Architecture _architecture;
15+
private static string _expectedErrorMessage;
16+
private static IArchRule _falseRule;
17+
private static IArchRule _trueRule;
18+
19+
[ClassInitialize]
20+
public static void Setup(TestContext context)
21+
{
22+
_architecture = new ArchLoader()
23+
.LoadAssemblies(System.Reflection.Assembly.Load("ArchUnitNET.MSTestV3Tests"))
24+
.Build();
25+
_trueRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().Exist();
26+
_falseRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().NotExist();
27+
_expectedErrorMessage = _falseRule.Evaluate(_architecture).ToErrorMessage();
28+
}
29+
30+
[TestMethod]
31+
public void ArchRuleAssertTest()
32+
{
33+
ArchRuleAssert.FulfilsRule(_architecture, _trueRule);
34+
Assert.ThrowsExactly<AssertFailedException>(() =>
35+
ArchRuleAssert.FulfilsRule(_architecture, _falseRule)
36+
);
37+
Assert.AreEqual(
38+
_expectedErrorMessage,
39+
RemoveAssertionText(
40+
Assert
41+
.ThrowsExactly<AssertFailedException>(() =>
42+
ArchRuleAssert.FulfilsRule(_architecture, _falseRule)
43+
)
44+
.Message
45+
)
46+
);
47+
}
48+
49+
[TestMethod]
50+
public void ArchRuleExtensionsTest()
51+
{
52+
_architecture.CheckRule(_trueRule);
53+
_trueRule.Check(_architecture);
54+
Assert.ThrowsExactly<AssertFailedException>(() => _architecture.CheckRule(_falseRule));
55+
Assert.ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture));
56+
Assert.AreEqual(
57+
_expectedErrorMessage,
58+
RemoveAssertionText(
59+
Assert
60+
.ThrowsExactly<AssertFailedException>(() =>
61+
_architecture.CheckRule(_falseRule)
62+
)
63+
.Message
64+
)
65+
);
66+
Assert.AreEqual(
67+
_expectedErrorMessage,
68+
RemoveAssertionText(
69+
Assert
70+
.ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture))
71+
.Message
72+
)
73+
);
74+
}
75+
76+
private static string RemoveAssertionText(string exceptionMessage)
77+
{
78+
return exceptionMessage.Replace("Assert.Fail failed. ", string.Empty);
79+
}
80+
}
81+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using ArchUnitNET.Domain;
2+
using ArchUnitNET.Fluent;
3+
using ArchUnitNET.Fluent.Extensions;
4+
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
6+
namespace ArchUnitNET.MSTestV4
7+
{
8+
public static class ArchRuleAssert
9+
{
10+
/// <summary>
11+
/// Verifies that the architecture meets the criteria of the archrule.
12+
/// </summary>
13+
/// <param name="architecture">The architecture to be tested</param>
14+
/// <param name="archRule">The rule to test the architecture with</param>
15+
public static void FulfilsRule(Architecture architecture, IArchRule archRule)
16+
{
17+
if (!archRule.HasNoViolations(architecture))
18+
{
19+
Assert.Fail(archRule.Evaluate(architecture).ToErrorMessage());
20+
}
21+
}
22+
}
23+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using ArchUnitNET.Domain;
2+
using ArchUnitNET.Fluent;
3+
4+
namespace ArchUnitNET.MSTestV4
5+
{
6+
public static class ArchRuleExtensions
7+
{
8+
/// <summary>
9+
/// Verifies that the architecture meets the criteria of the archrule.
10+
/// </summary>
11+
/// <param name="archRule">The rule to test the architecture with</param>
12+
/// <param name="architecture">The architecture to be tested</param>
13+
public static void Check(this IArchRule archRule, Architecture architecture)
14+
{
15+
ArchRuleAssert.FulfilsRule(architecture, archRule);
16+
}
17+
18+
/// <summary>
19+
/// Verifies that the architecture meets the criteria of the archrule.
20+
/// </summary>
21+
/// <param name="architecture">The architecture to be tested</param>
22+
/// <param name="archRule">The rule to test the architecture with</param>
23+
public static void CheckRule(this Architecture architecture, IArchRule archRule)
24+
{
25+
ArchRuleAssert.FulfilsRule(architecture, archRule);
26+
}
27+
}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
4+
<IsPackable>true</IsPackable>
5+
<Title>ArchUnit C# MSTestV4 Extension</Title>
6+
<Description>MSTestV4 Extension for the C# Version of ArchUnit (see: archunit.org)</Description>
7+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
8+
<RepositoryUrl>https://github.com/TNG/ArchUnitNET</RepositoryUrl>
9+
<PackageTags>test;arch;archunit;mstest;mstestv4</PackageTags>
10+
<IncludeSource>False</IncludeSource>
11+
<Company>TNG Technology Consulting GmbH</Company>
12+
<PackageId>TngTech.ArchUnitNET.MSTestV4</PackageId>
13+
<IsTestProject>false</IsTestProject>
14+
<IncludeSymbols>true</IncludeSymbols>
15+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
18+
</PropertyGroup>
19+
<ItemGroup>
20+
<PackageReference Include="MSTest.TestFramework" Version="4.0.0" />
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ProjectReference Include="..\ArchUnitNET\ArchUnitNET.csproj" />
24+
</ItemGroup>
25+
<ItemGroup>
26+
<None Include="../README.md" Pack="true" PackagePath="" />
27+
<None Include="../Logo/ArchUnitNET-Logo.png" Pack="true" PackagePath="/Logo/" />
28+
</ItemGroup>
29+
</Project>

0 commit comments

Comments
 (0)