From fc78c72fd507b01b1ee65d37525757ce8c35e813 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 21 Oct 2013 21:32:35 -0500 Subject: [PATCH] Add meta test to find missing [Fact]/[Theory] --- LibGit2Sharp.Tests/BranchFixture.cs | 1 + LibGit2Sharp.Tests/MetaFixture.cs | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs index d817ad2e6..bdb2d6736 100644 --- a/LibGit2Sharp.Tests/BranchFixture.cs +++ b/LibGit2Sharp.Tests/BranchFixture.cs @@ -450,6 +450,7 @@ public void LookingOutABranchByNameWithBadParamsThrows() } } + [Fact] public void CanGetInformationFromUnbornBranch() { string repoPath = InitNewRepository(true); diff --git a/LibGit2Sharp.Tests/MetaFixture.cs b/LibGit2Sharp.Tests/MetaFixture.cs index d99f1fa9d..4fd0aa9b0 100644 --- a/LibGit2Sharp.Tests/MetaFixture.cs +++ b/LibGit2Sharp.Tests/MetaFixture.cs @@ -4,12 +4,37 @@ using System.Linq; using System.Reflection; using System.Text; +using LibGit2Sharp.Tests.TestHelpers; using Xunit; +using Xunit.Extensions; namespace LibGit2Sharp.Tests { public class MetaFixture { + [Fact] + public void PublicTestMethodsAreFactsOrTheories() + { + var exceptions = new[] + { + "LibGit2Sharp.Tests.FilterBranchFixture.Dispose", + }; + + var fixtures = from t in Assembly.GetAssembly(typeof(MetaFixture)).GetExportedTypes() + where t.IsPublic && !t.IsNested + where t.Namespace != typeof(BaseFixture).Namespace // Exclude helpers + let methods = t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public) + from m in methods + where !m.GetCustomAttributes(typeof(FactAttribute), false) + .Concat(m.GetCustomAttributes(typeof(TheoryAttribute), false)) + .Any() + let name = t.FullName + "." + m.Name + where !exceptions.Contains(name) + select name; + + Assert.Equal("", string.Join(Environment.NewLine, fixtures.ToArray())); + } + // Related to https://github.com/libgit2/libgit2sharp/pull/251 [Fact] public void TypesInLibGit2DecoratedWithDebuggerDisplayMustFollowTheStandardImplPattern()