-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from GeorgKreuzmayr/notdependon-errormessage
Improve Error Messages
- Loading branch information
Showing
2 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,77 @@ | ||
// Copyright 2019 Florian Gather <[email protected]> | ||
// Copyright 2019 Fritz Brandhuber <[email protected]> | ||
// Copyright 2020 Pavel Fischer <[email protected]> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
using System.Linq; | ||
using ArchUnitNET.Domain; | ||
using ArchUnitNET.Loader; | ||
using Xunit; | ||
using static ArchUnitNET.Fluent.ArchRuleDefinition; | ||
|
||
namespace ArchUnitNETTests.Fluent | ||
{ | ||
public class DependencyErrorMessageTests | ||
{ | ||
private static readonly Architecture Architecture = | ||
StaticTestArchitectures.ArchUnitNETTestArchitecture; | ||
|
||
[Fact] | ||
public void ErrorMessageType() | ||
{ | ||
var rule = Classes().That() | ||
.HaveFullNameMatching(typeof(DependencyErrorMessageTestClass).FullName) | ||
.Should().NotDependOnAny(typeof(ErrorMessageClass1), typeof(ErrorMessageClass2)); | ||
var failDescription = rule.Evaluate(Architecture).ToList().First().Description; | ||
Assert.DoesNotContain(typeof(string).FullName, failDescription); | ||
Assert.DoesNotContain(typeof(ErrorMessageClass2).FullName, failDescription); | ||
Assert.Contains(typeof(ErrorMessageClass1).FullName, failDescription); | ||
} | ||
|
||
[Fact] | ||
public void ErrorMessageIType() | ||
{ | ||
var dependencyClass = Classes().That().HaveFullNameMatching(typeof(ErrorMessageClass1).FullName).Or().HaveFullNameMatching(typeof(ErrorMessageClass2).FullName) | ||
.GetObjects(Architecture).ToList(); | ||
var rule = Classes().That() | ||
.HaveFullNameMatching(typeof(DependencyErrorMessageTestClass).FullName) | ||
.Should().NotDependOnAny(dependencyClass); | ||
var failDescription = rule.Evaluate(Architecture).ToList().First().Description; | ||
Assert.DoesNotContain(typeof(string).FullName, failDescription); | ||
Assert.DoesNotContain(typeof(ErrorMessageClass2).FullName, failDescription); | ||
Assert.Contains(typeof(ErrorMessageClass1).FullName, failDescription); | ||
} | ||
|
||
[Fact] | ||
public void ErrorMessageIObjectProvider() | ||
{ | ||
var dependencyClass = Classes().That().HaveFullNameMatching(typeof(ErrorMessageClass1).FullName).Or() | ||
.HaveFullNameMatching(typeof(ErrorMessageClass2).FullName); | ||
var rule = Classes().That() | ||
.HaveFullNameMatching(typeof(DependencyErrorMessageTestClass).FullName) | ||
.Should().NotDependOnAny(dependencyClass); | ||
var failDescription = rule.Evaluate(Architecture).ToList().First().Description; | ||
Assert.DoesNotContain(typeof(string).FullName, failDescription); | ||
Assert.DoesNotContain(typeof(ErrorMessageClass2).FullName, failDescription); | ||
Assert.Contains(typeof(ErrorMessageClass1).FullName, failDescription); | ||
} | ||
} | ||
|
||
public class DependencyErrorMessageTestClass | ||
{ | ||
ErrorMessageClass1 testData = new ErrorMessageClass1(); | ||
private string testString = ""; | ||
} | ||
|
||
public class ErrorMessageClass1 | ||
{ | ||
|
||
} | ||
|
||
public class ErrorMessageClass2 | ||
{ | ||
|
||
} | ||
} |