-
Notifications
You must be signed in to change notification settings - Fork 73
Add MSTestV4 Support #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SeMuell
wants to merge
2
commits into
TNG:main
Choose a base branch
from
SeMuell:feat/add_MSTestV4_support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add MSTestV4 Support #426
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
22 changes: 22 additions & 0 deletions
22
ArchUnitNET.MSTestV3Tests/ArchUnitNET.MSTestV3Tests.csproj
This file contains hidden or 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,22 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <IsPackable>false</IsPackable> | ||
| <Company>TNG Technology Consulting GmbH</Company> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="MSTest" Version="3.10.4" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\ArchUnitNET.MSTestV2\ArchUnitNET.MSTestV2.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or 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,81 @@ | ||
| using ArchUnitNET.Domain; | ||
| using ArchUnitNET.Fluent; | ||
| using ArchUnitNET.Fluent.Extensions; | ||
| using ArchUnitNET.Loader; | ||
| using ArchUnitNET.MSTestV2; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using static ArchUnitNET.Fluent.ArchRuleDefinition; | ||
|
|
||
| namespace ArchUnitNET.MSTestV3Tests | ||
| { | ||
| [TestClass] | ||
| public class RuleEvaluationTests | ||
| { | ||
| private static Architecture _architecture; | ||
| private static string _expectedErrorMessage; | ||
| private static IArchRule _falseRule; | ||
| private static IArchRule _trueRule; | ||
|
|
||
| [ClassInitialize] | ||
| public static void Setup(TestContext context) | ||
| { | ||
| _architecture = new ArchLoader() | ||
| .LoadAssemblies(System.Reflection.Assembly.Load("ArchUnitNET.MSTestV3Tests")) | ||
| .Build(); | ||
| _trueRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().Exist(); | ||
| _falseRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().NotExist(); | ||
| _expectedErrorMessage = _falseRule.Evaluate(_architecture).ToErrorMessage(); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void ArchRuleAssertTest() | ||
| { | ||
| ArchRuleAssert.FulfilsRule(_architecture, _trueRule); | ||
| Assert.ThrowsExactly<AssertFailedException>(() => | ||
| ArchRuleAssert.FulfilsRule(_architecture, _falseRule) | ||
| ); | ||
| Assert.AreEqual( | ||
| _expectedErrorMessage, | ||
| RemoveAssertionText( | ||
| Assert | ||
| .ThrowsExactly<AssertFailedException>(() => | ||
| ArchRuleAssert.FulfilsRule(_architecture, _falseRule) | ||
| ) | ||
| .Message | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void ArchRuleExtensionsTest() | ||
| { | ||
| _architecture.CheckRule(_trueRule); | ||
| _trueRule.Check(_architecture); | ||
| Assert.ThrowsExactly<AssertFailedException>(() => _architecture.CheckRule(_falseRule)); | ||
| Assert.ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture)); | ||
| Assert.AreEqual( | ||
| _expectedErrorMessage, | ||
| RemoveAssertionText( | ||
| Assert | ||
| .ThrowsExactly<AssertFailedException>(() => | ||
| _architecture.CheckRule(_falseRule) | ||
| ) | ||
| .Message | ||
| ) | ||
| ); | ||
| Assert.AreEqual( | ||
| _expectedErrorMessage, | ||
| RemoveAssertionText( | ||
| Assert | ||
| .ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture)) | ||
| .Message | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| private static string RemoveAssertionText(string exceptionMessage) | ||
| { | ||
| return exceptionMessage.Replace("Assert.Fail failed. ", string.Empty); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,23 @@ | ||
| using ArchUnitNET.Domain; | ||
| using ArchUnitNET.Fluent; | ||
| using ArchUnitNET.Fluent.Extensions; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace ArchUnitNET.MSTestV4 | ||
| { | ||
| public static class ArchRuleAssert | ||
| { | ||
| /// <summary> | ||
| /// Verifies that the architecture meets the criteria of the archrule. | ||
| /// </summary> | ||
| /// <param name="architecture">The architecture to be tested</param> | ||
| /// <param name="archRule">The rule to test the architecture with</param> | ||
| public static void FulfilsRule(Architecture architecture, IArchRule archRule) | ||
| { | ||
| if (!archRule.HasNoViolations(architecture)) | ||
| { | ||
| Assert.Fail(archRule.Evaluate(architecture).ToErrorMessage()); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,28 @@ | ||
| using ArchUnitNET.Domain; | ||
| using ArchUnitNET.Fluent; | ||
|
|
||
| namespace ArchUnitNET.MSTestV4 | ||
| { | ||
| public static class ArchRuleExtensions | ||
| { | ||
| /// <summary> | ||
| /// Verifies that the architecture meets the criteria of the archrule. | ||
| /// </summary> | ||
| /// <param name="archRule">The rule to test the architecture with</param> | ||
| /// <param name="architecture">The architecture to be tested</param> | ||
| public static void Check(this IArchRule archRule, Architecture architecture) | ||
| { | ||
| ArchRuleAssert.FulfilsRule(architecture, archRule); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies that the architecture meets the criteria of the archrule. | ||
| /// </summary> | ||
| /// <param name="architecture">The architecture to be tested</param> | ||
| /// <param name="archRule">The rule to test the architecture with</param> | ||
| public static void CheckRule(this Architecture architecture, IArchRule archRule) | ||
| { | ||
| ArchRuleAssert.FulfilsRule(architecture, archRule); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,29 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>netstandard2.0;net462</TargetFrameworks> | ||
| <IsPackable>true</IsPackable> | ||
| <Title>ArchUnit C# MSTestV4 Extension</Title> | ||
| <Description>MSTestV4 Extension for the C# Version of ArchUnit (see: archunit.org)</Description> | ||
| <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
| <RepositoryUrl>https://github.com/TNG/ArchUnitNET</RepositoryUrl> | ||
| <PackageTags>test;arch;archunit;mstest;mstestv4</PackageTags> | ||
| <IncludeSource>False</IncludeSource> | ||
| <Company>TNG Technology Consulting GmbH</Company> | ||
| <PackageId>TngTech.ArchUnitNET.MSTestV4</PackageId> | ||
| <IsTestProject>false</IsTestProject> | ||
| <IncludeSymbols>true</IncludeSymbols> | ||
| <SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
| <PackageReadmeFile>README.md</PackageReadmeFile> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="MSTest.TestFramework" Version="4.0.0" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\ArchUnitNET\ArchUnitNET.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <None Include="../README.md" Pack="true" PackagePath="" /> | ||
| <None Include="../Logo/ArchUnitNET-Logo.png" Pack="true" PackagePath="/Logo/" /> | ||
| </ItemGroup> | ||
| </Project> |
22 changes: 22 additions & 0 deletions
22
ArchUnitNET.MSTestV4Tests/ArchUnitNET.MSTestV4Tests.csproj
This file contains hidden or 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,22 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <IsPackable>false</IsPackable> | ||
| <Company>TNG Technology Consulting GmbH</Company> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="MSTest" Version="4.0.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\ArchUnitNET.MSTestV4\ArchUnitNET.MSTestV4.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or 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 @@ | ||
| [assembly: DoNotParallelize] | ||
This file contains hidden or 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,81 @@ | ||
| using ArchUnitNET.Domain; | ||
| using ArchUnitNET.Fluent; | ||
| using ArchUnitNET.Fluent.Extensions; | ||
| using ArchUnitNET.Loader; | ||
| using ArchUnitNET.MSTestV4; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using static ArchUnitNET.Fluent.ArchRuleDefinition; | ||
|
|
||
| namespace ArchUnitNET.MSTestV4Tests | ||
| { | ||
| [TestClass] | ||
| public class RuleEvaluationTests | ||
| { | ||
| private static Architecture _architecture; | ||
| private static string _expectedErrorMessage; | ||
| private static IArchRule _falseRule; | ||
| private static IArchRule _trueRule; | ||
|
|
||
| [ClassInitialize] | ||
| public static void Setup(TestContext context) | ||
| { | ||
| _architecture = new ArchLoader() | ||
| .LoadAssemblies(System.Reflection.Assembly.Load("ArchUnitNET.MSTestV4Tests")) | ||
| .Build(); | ||
| _trueRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().Exist(); | ||
| _falseRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().NotExist(); | ||
| _expectedErrorMessage = _falseRule.Evaluate(_architecture).ToErrorMessage(); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void ArchRuleAssertTest() | ||
| { | ||
| ArchRuleAssert.FulfilsRule(_architecture, _trueRule); | ||
| Assert.ThrowsExactly<AssertFailedException>(() => | ||
| ArchRuleAssert.FulfilsRule(_architecture, _falseRule) | ||
| ); | ||
| Assert.AreEqual( | ||
| _expectedErrorMessage, | ||
| RemoveAssertionText( | ||
| Assert | ||
| .ThrowsExactly<AssertFailedException>(() => | ||
| ArchRuleAssert.FulfilsRule(_architecture, _falseRule) | ||
| ) | ||
| .Message | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void ArchRuleExtensionsTest() | ||
| { | ||
| _architecture.CheckRule(_trueRule); | ||
| _trueRule.Check(_architecture); | ||
| Assert.ThrowsExactly<AssertFailedException>(() => _architecture.CheckRule(_falseRule)); | ||
| Assert.ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture)); | ||
| Assert.AreEqual( | ||
| _expectedErrorMessage, | ||
| RemoveAssertionText( | ||
| Assert | ||
| .ThrowsExactly<AssertFailedException>(() => | ||
| _architecture.CheckRule(_falseRule) | ||
| ) | ||
| .Message | ||
| ) | ||
| ); | ||
| Assert.AreEqual( | ||
| _expectedErrorMessage, | ||
| RemoveAssertionText( | ||
| Assert | ||
| .ThrowsExactly<AssertFailedException>(() => _falseRule.Check(_architecture)) | ||
| .Message | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| private static string RemoveAssertionText(string exceptionMessage) | ||
| { | ||
| return exceptionMessage.Replace("Assert.Fail failed. ", string.Empty); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-generated file... I do not see a need for this.