Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r--LibGit2Sharp.Tests/BranchFixture.cs2
-rw-r--r--LibGit2Sharp.Tests/CheckoutFixture.cs3
-rw-r--r--LibGit2Sharp.Tests/MetaFixture.cs25
-rw-r--r--LibGit2Sharp.Tests/RemoteFixture.cs2
-rw-r--r--LibGit2Sharp.Tests/SubmoduleFixture.cs1
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs6
6 files changed, 38 insertions, 1 deletions
diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs
index d954e6a5..0aef1a27 100644
--- a/LibGit2Sharp.Tests/BranchFixture.cs
+++ b/LibGit2Sharp.Tests/BranchFixture.cs
@@ -75,6 +75,7 @@ namespace LibGit2Sharp.Tests
// The branch now exists...
Branch orphan = repo.Branches["orphan"];
Assert.NotNull(orphan);
+ AssertBelongsToARepository(repo, orphan);
// ...and points to that newly created commit
Assert.Equal(c, orphan.Tip);
@@ -489,6 +490,7 @@ namespace LibGit2Sharp.Tests
Assert.True(master.IsTracking);
Assert.NotNull(master.TrackedBranch);
+ AssertBelongsToARepository(repo, master.TrackedBranch);
Assert.NotNull(master.TrackingDetails);
Assert.Equal(9, master.TrackingDetails.AheadBy);
diff --git a/LibGit2Sharp.Tests/CheckoutFixture.cs b/LibGit2Sharp.Tests/CheckoutFixture.cs
index abe4ad9a..b3a09564 100644
--- a/LibGit2Sharp.Tests/CheckoutFixture.cs
+++ b/LibGit2Sharp.Tests/CheckoutFixture.cs
@@ -32,9 +32,11 @@ namespace LibGit2Sharp.Tests
Branch branch = repo.Branches[branchName];
Assert.NotNull(branch);
+ AssertBelongsToARepository(repo, branch);
Branch test = repo.Checkout(branch);
Assert.False(repo.Info.IsHeadDetached);
+ AssertBelongsToARepository(repo, test);
Assert.False(test.IsRemote);
Assert.True(test.IsCurrentRepositoryHead);
@@ -114,6 +116,7 @@ namespace LibGit2Sharp.Tests
Assert.False(repo.Index.RetrieveStatus().IsDirty);
var commit = repo.Lookup<Commit>(commitPointer);
+ AssertBelongsToARepository(repo, commit);
Branch detachedHead = checkoutByCommitOrBranchSpec ? repo.Checkout(commitPointer) : repo.Checkout(commit);
diff --git a/LibGit2Sharp.Tests/MetaFixture.cs b/LibGit2Sharp.Tests/MetaFixture.cs
index 3cff83cc..fb1b567c 100644
--- a/LibGit2Sharp.Tests/MetaFixture.cs
+++ b/LibGit2Sharp.Tests/MetaFixture.cs
@@ -12,6 +12,11 @@ namespace LibGit2Sharp.Tests
{
public class MetaFixture
{
+ private static readonly HashSet<Type> explicitOnlyInterfaces = new HashSet<Type>
+ {
+ typeof(IBelongToARepository),
+ };
+
[Fact]
public void PublicTestMethodsAreFactsOrTheories()
{
@@ -114,7 +119,7 @@ namespace LibGit2Sharp.Tests
var methodsMissingFromInterfaces =
from t in Assembly.GetAssembly(typeof(IRepository)).GetExportedTypes()
where !t.IsInterface
- where t.GetInterfaces().Any(i => i.IsPublic && i.Namespace == typeof(IRepository).Namespace)
+ where t.GetInterfaces().Any(i => i.IsPublic && i.Namespace == typeof(IRepository).Namespace && !explicitOnlyInterfaces.Contains(i))
let interfaceTargetMethods = from i in t.GetInterfaces()
from im in t.GetInterfaceMap(i).TargetMethods
select im
@@ -127,6 +132,24 @@ namespace LibGit2Sharp.Tests
}
[Fact]
+ public void LibGit2SharpExplicitOnlyInterfacesAreIndeedExplicitOnly()
+ {
+ var methodsMissingFromInterfaces =
+ from t in Assembly.GetAssembly(typeof(IRepository)).GetExportedTypes()
+ where t.GetInterfaces().Any(explicitOnlyInterfaces.Contains)
+ let interfaceTargetMethods = from i in t.GetInterfaces()
+ where explicitOnlyInterfaces.Contains(i)
+ from im in t.GetInterfaceMap(i).TargetMethods
+ select im
+ from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
+ where interfaceTargetMethods.Contains(tm)
+ select t.Name + " has public method " + tm.Name + " which should be explicitly implemented.";
+
+ Assert.Equal("", string.Join(Environment.NewLine,
+ methodsMissingFromInterfaces.ToArray()));
+ }
+
+ [Fact]
public void EnumsWithFlagsHaveMutuallyExclusiveValues()
{
var flagsEnums = Assembly.GetAssembly(typeof(IRepository)).GetExportedTypes()
diff --git a/LibGit2Sharp.Tests/RemoteFixture.cs b/LibGit2Sharp.Tests/RemoteFixture.cs
index 72a2fa67..0299860a 100644
--- a/LibGit2Sharp.Tests/RemoteFixture.cs
+++ b/LibGit2Sharp.Tests/RemoteFixture.cs
@@ -14,6 +14,7 @@ namespace LibGit2Sharp.Tests
{
Remote origin = repo.Network.Remotes["origin"];
Assert.NotNull(origin);
+ AssertBelongsToARepository(repo, origin);
Assert.Equal("origin", origin.Name);
Assert.Equal("c:/GitHub/libgit2sharp/Resources/testrepo.git", origin.Url);
}
@@ -38,6 +39,7 @@ namespace LibGit2Sharp.Tests
foreach (Remote remote in repo.Network.Remotes)
{
Assert.NotNull(remote);
+ AssertBelongsToARepository(repo, remote);
count++;
}
diff --git a/LibGit2Sharp.Tests/SubmoduleFixture.cs b/LibGit2Sharp.Tests/SubmoduleFixture.cs
index e1b378b7..2463912f 100644
--- a/LibGit2Sharp.Tests/SubmoduleFixture.cs
+++ b/LibGit2Sharp.Tests/SubmoduleFixture.cs
@@ -60,6 +60,7 @@ namespace LibGit2Sharp.Tests
{
var submodule = repo.Submodules[name];
Assert.NotNull(submodule);
+ AssertBelongsToARepository(repo, submodule);
Assert.Equal(name, submodule.Name);
Assert.Equal((ObjectId)headId, submodule.HeadCommitId);
diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index b01d04c4..0200a256 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -412,5 +412,11 @@ namespace LibGit2Sharp.Tests.TestHelpers
return true;
}
+
+ public void AssertBelongsToARepository<T>(IRepository repo, T instance)
+ where T : IBelongToARepository
+ {
+ Assert.Same(repo, ((IBelongToARepository)instance).Repository);
+ }
}
}