Skip to content

Commit bedccca

Browse files
committed
Add test for interface coverage
Closes #546
1 parent 2e96549 commit bedccca

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

LibGit2Sharp.Tests/MetaFixture.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@ public void TypesInLibGit2SharpMustBeExtensibleInATestingContext()
108108
}
109109
}
110110

111+
[Fact]
112+
public void LibGit2SharpInterfacesCoverAllPublicMembers()
113+
{
114+
var methodsMissingFromInterfaces =
115+
from t in Assembly.GetAssembly(typeof(IRepository)).GetExportedTypes()
116+
where !t.IsInterface
117+
where t.GetInterfaces().Any(i => i.Namespace == typeof(IRepository).Namespace)
118+
let interfaceTargetMethods = from i in t.GetInterfaces()
119+
from im in t.GetInterfaceMap(i).TargetMethods
120+
select im
121+
from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
122+
where !interfaceTargetMethods.Contains(tm)
123+
select t.Name + " has extra method " + tm.Name;
124+
125+
Assert.Equal("", string.Join(Environment.NewLine,
126+
methodsMissingFromInterfaces.ToArray()));
127+
}
128+
111129
[Fact]
112130
public void EnumsWithFlagsHaveMutuallyExclusiveValues()
113131
{

0 commit comments

Comments
 (0)