Skip to content

Commit c99e54d

Browse files
committed
Move tests out of desktop folder
1 parent 23f4db4 commit c99e54d

File tree

3 files changed

+37
-47
lines changed

3 files changed

+37
-47
lines changed

LibGit2Sharp.Tests/MetaFixture.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,49 @@
1313

1414
namespace LibGit2Sharp.Tests
1515
{
16-
public partial class MetaFixture
16+
public class MetaFixture
1717
{
1818
private static readonly HashSet<Type> explicitOnlyInterfaces = new HashSet<Type>
1919
{
2020
typeof(IBelongToARepository), typeof(IDiffResult),
2121
};
2222

23+
[Fact]
24+
public void LibGit2SharpPublicInterfacesCoverAllPublicMembers()
25+
{
26+
var methodsMissingFromInterfaces =
27+
from t in typeof(IRepository).GetTypeInfo().Assembly.GetExportedTypes()
28+
where !t.GetTypeInfo().IsInterface
29+
where t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsPublic && i.Namespace == typeof(IRepository).Namespace && !explicitOnlyInterfaces.Contains(i))
30+
let interfaceTargetMethods = from i in t.GetTypeInfo().GetInterfaces()
31+
from im in t.GetInterfaceMap(i).TargetMethods
32+
select im
33+
from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
34+
where !interfaceTargetMethods.Contains(tm)
35+
select t.Name + " has extra method " + tm.Name;
36+
37+
Assert.Equal("", string.Join(Environment.NewLine,
38+
methodsMissingFromInterfaces.ToArray()));
39+
}
40+
41+
[Fact]
42+
public void LibGit2SharpExplicitOnlyInterfacesAreIndeedExplicitOnly()
43+
{
44+
var methodsMissingFromInterfaces =
45+
from t in typeof(IRepository).GetTypeInfo().Assembly.GetExportedTypes()
46+
where t.GetInterfaces().Any(explicitOnlyInterfaces.Contains)
47+
let interfaceTargetMethods = from i in t.GetInterfaces()
48+
where explicitOnlyInterfaces.Contains(i)
49+
from im in t.GetTypeInfo().GetInterfaceMap(i).TargetMethods
50+
select im
51+
from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
52+
where interfaceTargetMethods.Contains(tm)
53+
select t.Name + " has public method " + tm.Name + " which should be explicitly implemented.";
54+
55+
Assert.Equal("", string.Join(Environment.NewLine,
56+
methodsMissingFromInterfaces.ToArray()));
57+
}
58+
2359
[Fact]
2460
public void PublicTestMethodsAreFactsOrTheories()
2561
{

LibGit2Sharp.Tests/desktop/MetaFixture.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)