8000 Add meta test to find missing [Fact]/[Theory] · philhack/libgit2sharp@fc78c72 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc78c72

Browse files
committed
Add meta test to find missing [Fact]/[Theory]
1 parent abc7b61 commit fc78c72

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ public void LookingOutABranchByNameWithBadParamsThrows()
450450
}
451451
}
452452

453+
[Fact]
453454
public void CanGetInformationFromUnbornBranch()
454455
{
455456
string repoPath = InitNewRepository(true);

LibGit2Sharp.Tests/MetaFixture.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,37 @@
44
using System.Linq;
55
using System.Reflection;
66
using System.Text;
7+
using LibGit2Sharp.Tests.TestHelpers;
78
using Xunit;
9+
using Xunit.Extensions;
810

911
namespace LibGit2Sharp.Tests
1012
{
1113
public class MetaFixture
1214
{
15+
[Fact]
16+
public void PublicTestMethodsAreFactsOrTheories()
17+
{
18+
var exceptions = new[]
19+
{
20+
"LibGit2Sharp.Tests.FilterBranchFixture.Dispose",
21+
};
22+
23+
var fixtures = from t in Assembly.GetAssembly(typeof(MetaFixture)).GetExportedTypes()
24+
where t.IsPublic && !t.IsNested
25+
where t.Namespace != typeof(BaseFixture).Namespace // Exclude helpers
26+
let methods = t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)
27+
from m in methods
28+
where !m.GetCustomAttributes(typeof(FactAttribute), false)
29+
.Concat(m.GetCustomAttributes(typeof(TheoryAttribute), false))
30+
.Any()
31+
let name = t.FullName + "." + m.Name
32+
where !exceptions.Contains(name)
33+
select name;
34+
35+
Assert.Equal("", string.Join(Environment.NewLine, fixtures.ToArray()));
36+
}
37+
1338
// Related to https://github.com/libgit2/libgit2sharp/pull/251
1439
[Fact]
1540
public void TypesInLibGit2DecoratedWithDebuggerDisplayMustFollowTheStandardImplPattern()

0 commit comments

Comments
 (0)
0