Skip to content

Commit

Permalink
implement testcase from PR #110
Browse files Browse the repository at this point in the history
Signed-off-by: Fritz Brandhuber <[email protected]>
  • Loading branch information
brandhuf committed Sep 20, 2021
1 parent 1ea237d commit 296d512
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ArchUnitNETTests/Domain/AttributeArgumentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void FluentPredicatesTest()
.HaveAnyAttributesWithNamedArguments(("Parameter2", "param2_1"), ("Parameter3", "param3_2")).Should()
.Exist().Check(Architecture);
Types().That().Are(typeof(ClassWithMultipleAttributesWithParameters)).And()
.HaveAnyAttributesWithArguments(1).Should()
.HaveAnyAttributesWithArguments(null).Should()
.Exist().Check(Architecture);
Types().That().Are(typeof(ClassWithTypeParameterAttribute)).And()
.HaveAnyAttributesWithArguments(typeof(ClassWithArrayParameterAttribute)).Should()
Expand Down Expand Up @@ -151,7 +151,7 @@ public void FluentPredicatesTest()
.Should()
.NotExist().Check(Architecture);
Types().That().Are(typeof(ClassWithMultipleAttributesWithParameters)).And()
.DoNotHaveAnyAttributesWithArguments(1).Should()
.DoNotHaveAnyAttributesWithArguments(null).Should()
.NotExist().Check(Architecture);
Types().That().Are(typeof(ClassWithTypeParameterAttribute)).And()
.DoNotHaveAnyAttributesWithArguments(typeof(ClassWithArrayParameterAttribute)).Should()
Expand Down Expand Up @@ -188,7 +188,7 @@ public void FluentConditionsTest()
.HaveAnyAttributesWithNamedArguments(("Parameter2", "param2_1"), ("Parameter3", "param3_2"))
.Check(Architecture);
Types().That().Are(typeof(ClassWithMultipleAttributesWithParameters)).Should()
.HaveAnyAttributesWithArguments(1).Check(Architecture);
.HaveAnyAttributesWithArguments(null).Check(Architecture);
Types().That().Are(typeof(ClassWithTypeParameterAttribute)).Should()
.HaveAnyAttributesWithArguments(typeof(ClassWithArrayParameterAttribute)).Check(Architecture);
Types().That().Are(typeof(ClassWithTypeParameterAttribute)).Should()
Expand Down Expand Up @@ -227,7 +227,7 @@ public void FluentConditionsTest()
.Check(Architecture));
Assert.Throws<FailedArchRuleException>(() => Types().That()
.Are(typeof(ClassWithMultipleAttributesWithParameters)).Should()
.NotHaveAnyAttributesWithArguments(1).Check(Architecture));
.NotHaveAnyAttributesWithArguments(null).Check(Architecture));
Assert.Throws<FailedArchRuleException>(() => Types().That().Are(typeof(ClassWithTypeParameterAttribute))
.Should()
.NotHaveAnyAttributesWithArguments(typeof(ClassWithArrayParameterAttribute)).Check(Architecture));
Expand Down Expand Up @@ -270,9 +270,12 @@ public AttributeWithStringParameters(string parameter1, string parameter2)

internal class AttributeWithObjectParameter : Attribute
{
public AttributeWithObjectParameter(object type)
public AttributeWithObjectParameter(params object[] arguments)
{
}

public AttributeWithObjectParameter(object arg)
{
Type = type;
}

public object Type { get; }
Expand All @@ -283,7 +286,7 @@ public AttributeWithObjectParameter(object type)
[AttributeWithStringParameters("param1_0")]
[AttributeWithStringParameters("param1_1", Parameter2 = "param2_1")]
[AttributeWithStringParameters("param1_2", "param2_2", Parameter3 = "param3_2")]
[AttributeWithObjectParameter(1)]
[AttributeWithObjectParameter(null)]
internal class ClassWithMultipleAttributesWithParameters
{
}
Expand Down

0 comments on commit 296d512

Please sign in to comment.