Skip to content
Permalink
Browse files

Sandbox every test

Fix #826
  • Loading branch information
nulltoken committed Jan 2, 2015
1 parent 7e57858 commit 27fbde62110b2fb40f537ac14da620410fc0888e
Showing with 569 additions and 312 deletions.
  1. +6 −3 LibGit2Sharp.Tests/ArchiveFixture.cs
  2. +10 −5 LibGit2Sharp.Tests/BlameFixture.cs
  3. +10 −5 LibGit2Sharp.Tests/BlobFixture.cs
  4. +52 −26 LibGit2Sharp.Tests/BranchFixture.cs
  5. +8 −4 LibGit2Sharp.Tests/CheckoutFixture.cs
  6. +2 −1 LibGit2Sharp.Tests/CleanFixture.cs
  7. +1 −1 LibGit2Sharp.Tests/CloneFixture.cs
  8. +8 −4 LibGit2Sharp.Tests/CommitAncestorFixture.cs
  9. +38 −20 LibGit2Sharp.Tests/CommitFixture.cs
  10. +28 −14 LibGit2Sharp.Tests/ConfigurationFixture.cs
  11. +5 −3 LibGit2Sharp.Tests/ConflictFixture.cs
  12. +2 −1 LibGit2Sharp.Tests/CurrentOperationFixture.cs
  13. +8 −4 LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs
  14. +12 −6 LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs
  15. +26 −13 LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs
  16. +10 −5 LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs
  17. +4 −2 LibGit2Sharp.Tests/IgnoreFixture.cs
  18. +15 −8 LibGit2Sharp.Tests/IndexFixture.cs
  19. +6 −3 LibGit2Sharp.Tests/MergeFixture.cs
  20. +2 −1 LibGit2Sharp.Tests/MockingFixture.cs
  21. +12 −6 LibGit2Sharp.Tests/NoteFixture.cs
  22. +20 −10 LibGit2Sharp.Tests/ObjectDatabaseFixture.cs
  23. +2 −1 LibGit2Sharp.Tests/PatchStatsFixture.cs
  24. +47 −28 LibGit2Sharp.Tests/ReferenceFixture.cs
  25. +6 −4 LibGit2Sharp.Tests/ReflogFixture.cs
  26. +14 −7 LibGit2Sharp.Tests/RemoteFixture.cs
  27. +6 −3 LibGit2Sharp.Tests/RemoveFixture.cs
  28. +44 −22 LibGit2Sharp.Tests/RepositoryFixture.cs
  29. +9 −5 LibGit2Sharp.Tests/RepositoryOptionsFixture.cs
  30. +6 −3 LibGit2Sharp.Tests/ResetHeadFixture.cs
  31. +2 −1 LibGit2Sharp.Tests/ResetIndexFixture.cs
  32. +8 −4 LibGit2Sharp.Tests/StageFixture.cs
  33. +4 −2 LibGit2Sharp.Tests/StashFixture.cs
  34. +4 −2 LibGit2Sharp.Tests/StatusFixture.cs
  35. +44 −22 LibGit2Sharp.Tests/TagFixture.cs
  36. +18 −27 LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
  37. +40 −20 LibGit2Sharp.Tests/TreeDefinitionFixture.cs
  38. +26 −13 LibGit2Sharp.Tests/TreeFixture.cs
  39. +2 −1 LibGit2Sharp.Tests/UnstageFixture.cs
  40. +2 −2 LibGit2Sharp.v2.ncrunchsolution
@@ -11,7 +11,8 @@ public class ArchiveFixture : BaseFixture
[Fact]
public void CanArchiveATree()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var tree = repo.Lookup<Tree>("581f9824ecaf824221bd36edf5430f2739a7c4f5");

@@ -36,7 +37,8 @@ public void CanArchiveATree()
[Fact]
public void CanArchiveACommit()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var commit = repo.Lookup<Commit>("4c062a6361ae6959e06292c1fa5e2822d9c96345");

@@ -61,7 +63,8 @@ public void CanArchiveACommit()
[Fact]
public void ArchivingANullTreeOrCommitThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive((Commit)null, null));
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive((Tree)null, null));
@@ -22,7 +22,8 @@ private static void AssertCorrectHeadBlame(BlameHunkCollection blame)
[Fact]
public void CanBlameSimply()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
AssertCorrectHeadBlame(repo.Blame("README"));
}
@@ -31,7 +32,8 @@ public void CanBlameSimply()
[Fact]
public void CanBlameFromADifferentCommit()
{
using (var repo = new Repository(MergedTestRepoWorkingDirPath))
string path = SandboxMergedTestRepo();
using (var repo = new Repository(path))
{
// File doesn't exist at HEAD
Assert.Throws<LibGit2SharpException>(() => repo.Blame("ancestor-only.txt"));
@@ -44,7 +46,8 @@ public void CanBlameFromADifferentCommit()
[Fact]
public void ValidatesLimits()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var blame = repo.Blame("README");

@@ -56,7 +59,8 @@ public void ValidatesLimits()
[Fact]
public void CanBlameFromVariousTypes()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = "HEAD" }));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = repo.Head }));
@@ -68,7 +72,8 @@ public void CanBlameFromVariousTypes()
[Fact]
public void CanStopBlame()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
// $ git blame .\new.txt
// 9fd738e8 (Scott Chacon 2010-05-24 10:19:19 -0700 1) my new file
@@ -12,7 +12,8 @@ public class BlobFixture : BaseFixture
[Fact]
public void CanGetBlobAsText()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");

@@ -86,7 +87,8 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect
[Fact]
public void CanGetBlobSize()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
Assert.Equal(10, blob.Size);
@@ -96,7 +98,8 @@ public void CanGetBlobSize()
[Fact]
public void CanLookUpBlob()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
Assert.NotNull(blob);
@@ -106,7 +109,8 @@ public void CanLookUpBlob()
[Fact]
public void CanReadBlobStream()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");

@@ -208,7 +212,8 @@ public void CanStageAFileGeneratedFromABlobContentStream()
[Fact]
public void CanTellIfTheBlobContentLooksLikeBinary()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
Assert.Equal(false, blob.IsBinary);
@@ -238,7 +238,8 @@ public void CreatingABranchTriggersTheCreationOfADirectReference()
[Fact]
public void CreatingABranchFromANonCommitObjectThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "sorry-dude-i-do-not-do-blobs-nor-trees";
Assert.Throws<InvalidSpecificationException>(() => repo.CreateBranch(name, "refs/tags/point_to_blob"));
@@ -250,7 +251,8 @@ public void CreatingABranchFromANonCommitObjectThrows()
[Fact]
public void CreatingBranchWithUnknownNamedTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Add("my_new_branch", "my_old_branch"));
}
@@ -259,7 +261,8 @@ public void CreatingBranchWithUnknownNamedTargetThrows()
[Fact]
public void CreatingBranchWithUnknownShaTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha.Substring(0, 7)));
@@ -269,7 +272,8 @@ public void CreatingBranchWithUnknownShaTargetThrows()
[Fact]
public void CreatingBranchWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<ArgumentNullException>(() => repo.Branches.Add(null, repo.Head.CanonicalName));
Assert.Throws<ArgumentException>(() => repo.Branches.Add(string.Empty, repo.Head.CanonicalName));
@@ -282,7 +286,8 @@ public void CreatingBranchWithBadParamsThrows()
[Fact]
public void CanListAllBranches()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Equal(expectedBranches, SortedBranches(repo.Branches, b => b.Name));

@@ -312,7 +317,8 @@ public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName()
[Fact]
public void CanListAllBranchesWhenGivenWorkingDir()
{
using (var repo = new Repository(StandardTestRepoWorkingDirPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
var expectedWdBranches = new[]
{
@@ -328,7 +334,8 @@ public void CanListAllBranchesWhenGivenWorkingDir()
[Fact]
public void CanListAllBranchesIncludingRemoteRefs()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
var expectedBranchesIncludingRemoteRefs = new[]
{
@@ -352,7 +359,8 @@ public void CanListAllBranchesIncludingRemoteRefs()
[Fact]
public void CanResolveRemote()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.Equal(repo.Network.Remotes["origin"], master.Remote);
@@ -362,7 +370,8 @@ public void CanResolveRemote()
[Fact]
public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Branch test = repo.Branches["i-do-numbers"];
Assert.Null(test.Remote);
@@ -374,7 +383,8 @@ public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull()
public void QueryRemoteForLocalTrackingBranch()
{
// There is not a Remote to resolve for a local tracking branch.
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Branch trackLocal = repo.Branches["track-local"];
Assert.Null(trackLocal.Remote);
@@ -384,7 +394,8 @@ public void QueryRemoteForLocalTrackingBranch()
[Fact]
public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Branch trackLocal = repo.Branches["track-local"];
Assert.Equal("refs/heads/master", trackLocal.UpstreamBranchCanonicalName);
@@ -394,7 +405,8 @@ public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch()
[Fact]
public void QueryRemoteForRemoteBranch()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
var master = repo.Branches["origin/master"];
Assert.Equal(repo.Network.Remotes["origin"], master.Remote);
@@ -452,7 +464,8 @@ public void QueryAmbigousRemoteForRemoteBranch()
[Fact]
public void CanLookupABranchByItsCanonicalName()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Branch branch = repo.Branches["refs/heads/br2"];
Assert.NotNull(branch);
@@ -470,7 +483,8 @@ public void CanLookupABranchByItsCanonicalName()
[Fact]
public void CanLookupLocalBranch()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.NotNull(master);
@@ -501,7 +515,8 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters()
[Fact]
public void LookingOutABranchByNameWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Branch branch;
Assert.Throws<ArgumentNullException>(() => branch = repo.Branches[null]);
@@ -587,7 +602,8 @@ public void TrackingInformationIsEmptyForBranchTrackingPrunedRemoteBranch()
[Fact]
public void TrackingInformationIsEmptyForNonTrackingBranch()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Branch branch = repo.Branches["test"];
Assert.False(branch.IsTracking);
@@ -603,7 +619,8 @@ public void TrackingInformationIsEmptyForNonTrackingBranch()
[Fact]
public void CanGetTrackingInformationForTrackingBranch()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsTracking);
@@ -619,7 +636,8 @@ public void CanGetTrackingInformationForTrackingBranch()
[Fact]
public void CanGetTrackingInformationForLocalTrackingBranch()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
var branch = repo.Branches["track-local"];
Assert.True(branch.IsTracking);
@@ -635,7 +653,8 @@ public void CanGetTrackingInformationForLocalTrackingBranch()
[Fact]
public void RenamingARemoteTrackingBranchThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["refs/remotes/origin/master"];
Assert.True(master.IsRemote);
@@ -647,7 +666,8 @@ public void RenamingARemoteTrackingBranchThrows()
[Fact]
public void CanWalkCommitsFromAnotherBranch()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["test"];
Assert.Equal(2, master.Commits.Count());
@@ -813,7 +833,8 @@ public void CanUnsetTrackedBranch()
[Fact]
public void CanWalkCommitsFromBranch()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.Equal(7, master.Commits.Count());
@@ -871,7 +892,8 @@ public void CanRemoveANonExistingBranch(string branchName, bool isRemote)
[Fact]
public void RemovingABranchWhichIsTheCurrentHeadThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Remove(repo.Head.Name));
}
@@ -880,7 +902,8 @@ public void RemovingABranchWhichIsTheCurrentHeadThrows()
[Fact]
public void RemovingABranchWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<ArgumentException>(() => repo.Branches.Remove(string.Empty));
Assert.Throws<ArgumentNullException>(() => repo.Branches.Remove(null));
@@ -890,7 +913,8 @@ public void RemovingABranchWithBadParamsThrows()
[Fact]
public void OnlyOneBranchIsTheHead()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Branch head = null;

@@ -957,7 +981,8 @@ public void CanRenameABranch()
[Fact]
public void BlindlyRenamingABranchOverAnExistingOneThrows()
{
using (var repo = new Repository(BareTestRepoPath))
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<NameConflictException>(() => repo.Branches.Rename("br2", "test"));
}
@@ -1068,7 +1093,8 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone()
[Fact]
public void RemoteBranchesDoNotTrackAnything()
{
using (var repo = new Repository(StandardTestRepoPath))
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
var branches = repo.Branches.Where(b => b.IsRemote);

0 comments on commit 27fbde6

Please sign in to comment.
You can’t perform that action at this time.