Skip to content

Commit

Permalink
Added unit test to ensure that compiler generated classes are ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorris committed Dec 14, 2019
1 parent d9fd70a commit 63a7212
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/NetArchTest.Rules.UnitTests/TypesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using NetArchTest.TestStructure.NameMatching.Namespace1;
using NetArchTest.TestStructure.NameMatching.Namespace2;
using NetArchTest.TestStructure.NameMatching.Namespace2.Namespace3;
Expand Down Expand Up @@ -95,5 +96,16 @@ public void FromFile_BadImage_CaughtAndEmptyListReturned()
// Assert
Assert.Empty(result);
}

[Fact(DisplayName = "Any compiler generated classes will be ignored in a types list.")]
public void InNamespace_CompilerGeneratedClasses_NotReturned()
{
// Act
var result = Types.InNamespace("NetArchTest.TestStructure.Dependencies.Search").GetTypes();

// Assert
var generated = result.Any(r => r.CustomAttributes.Any(x => x?.AttributeType?.FullName == typeof(CompilerGeneratedAttribute).FullName));
Assert.False(generated);
}
}
}

0 comments on commit 63a7212

Please sign in to comment.