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:
authornulltoken <emeric.fermas@gmail.com>2012-02-28 18:43:05 +0400
committernulltoken <emeric.fermas@gmail.com>2012-02-28 22:49:12 +0400
commit3e9348985d071912f0dfca41ea03251fe74093ef (patch)
tree8f9568ef4f5dcc204cdb39c5397443c9227065b8 /LibGit2Sharp.Tests
parent8da9472dc250d879d8cfae029cd8ee395edc9469 (diff)
Migrate unit tests to XUnit
Diffstat (limited to 'LibGit2Sharp.Tests')
-rwxr-xr-xLibGit2Sharp.Tests/BlobFixture.cs15
-rw-r--r--LibGit2Sharp.Tests/BranchFixture.cs86
-rw-r--r--LibGit2Sharp.Tests/CommitFixture.cs95
-rw-r--r--LibGit2Sharp.Tests/ConfigurationFixture.cs55
-rw-r--r--LibGit2Sharp.Tests/EpochFixture.cs77
-rw-r--r--LibGit2Sharp.Tests/IndexFixture.cs111
-rw-r--r--LibGit2Sharp.Tests/LazyFixture.cs9
-rw-r--r--LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj11
-rw-r--r--LibGit2Sharp.Tests/ObjectIdFixture.cs50
-rw-r--r--LibGit2Sharp.Tests/ReferenceFixture.cs85
-rw-r--r--LibGit2Sharp.Tests/RemoteFixture.cs11
-rw-r--r--LibGit2Sharp.Tests/RepositoryFixture.cs61
-rw-r--r--LibGit2Sharp.Tests/ResetFixture.cs23
-rw-r--r--LibGit2Sharp.Tests/StatusFixture.cs18
-rw-r--r--LibGit2Sharp.Tests/TagFixture.cs127
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs26
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs9
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/SkipException.cs14
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs31
-rwxr-xr-xLibGit2Sharp.Tests/TreeFixture.cs29
-rw-r--r--LibGit2Sharp.Tests/TupleFixture.cs17
21 files changed, 509 insertions, 451 deletions
diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs
index 60ab7d93..be8c10a3 100755
--- a/LibGit2Sharp.Tests/BlobFixture.cs
+++ b/LibGit2Sharp.Tests/BlobFixture.cs
@@ -1,14 +1,13 @@
using System.IO;
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class BlobFixture : BaseFixture
{
- [Test]
+ [Fact]
public void CanGetBlobAsUtf8()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -20,7 +19,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanGetBlobSize()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -30,7 +29,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanLookUpBlob()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -40,7 +39,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanReadBlobContent()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -54,7 +53,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanReadBlobStream()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -79,7 +78,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanStageAFileGeneratedFromABlobContentStream()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs
index 40259abc..8105ba65 100644
--- a/LibGit2Sharp.Tests/BranchFixture.cs
+++ b/LibGit2Sharp.Tests/BranchFixture.cs
@@ -1,16 +1,16 @@
using System;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class BranchFixture : BaseFixture
{
private readonly string[] expectedBranches = new[] { "br2", "master", "packed", "packed-test", "test", };
- [Test]
+ [Fact]
public void CanCreateBranch()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -29,7 +29,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateBranchUsingAbbreviatedSha()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -42,7 +42,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateBranchFromImplicitHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -60,7 +60,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateBranchFromExplicitHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -73,7 +73,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingABranchFromATagPeelsToTheCommit()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -86,7 +86,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingABranchTriggersTheCreationOfADirectReference()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -100,11 +100,11 @@ namespace LibGit2Sharp.Tests
Reference reference = repo.Refs[newBranch.CanonicalName];
reference.ShouldNotBeNull();
- Assert.IsInstanceOf(typeof(DirectReference), reference);
+ Assert.IsType(typeof(DirectReference), reference);
}
}
- [Test]
+ [Fact]
public void CreatingABranchFromANonCommitObjectThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -116,7 +116,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingBranchWithUnknownNamedTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -125,7 +125,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingBranchWithUnknownShaTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -135,7 +135,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingABranchPointingAtANonCanonicalReferenceThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -144,7 +144,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingBranchWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -156,29 +156,29 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanListAllBranches()
{
using (var repo = new Repository(BareTestRepoPath))
{
- CollectionAssert.AreEqual(expectedBranches, repo.Branches.Select(b => b.Name).ToArray());
+ Assert.Equal(expectedBranches, repo.Branches.Select(b => b.Name).ToArray());
repo.Branches.Count().ShouldEqual(5);
}
}
- [Test]
+ [Fact]
public void CanListAllBranchesWhenGivenWorkingDir()
{
using (var repo = new Repository(StandardTestRepoWorkingDirPath))
{
var expectedWdBranches = new[] { "master", "track-local", "origin/HEAD", "origin/br2", "origin/master", "origin/packed-test", "origin/test" };
- CollectionAssert.AreEqual(expectedWdBranches, repo.Branches.Select(b => b.Name).ToArray());
+ Assert.Equal(expectedWdBranches, repo.Branches.Select(b => b.Name).ToArray());
}
}
- [Test]
+ [Fact]
public void CanListAllBranchesIncludingRemoteRefs()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -193,11 +193,11 @@ namespace LibGit2Sharp.Tests
new { Name = "origin/packed-test", Sha = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", IsRemote = true },
new { Name = "origin/test", Sha = "e90810b8df3e80c413d903f631643c716887138d", IsRemote = true },
};
- CollectionAssert.AreEqual(expectedBranchesIncludingRemoteRefs, repo.Branches.Select(b => new { b.Name, b.Tip.Sha, b.IsRemote }).ToArray());
+ Assert.Equal(expectedBranchesIncludingRemoteRefs, repo.Branches.Select(b => new { b.Name, b.Tip.Sha, b.IsRemote }).ToArray());
}
}
- [Test]
+ [Fact]
public void CanLookupABranchByItsCanonicalName()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -215,7 +215,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanLookupLocalBranch()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -230,7 +230,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void LookingOutABranchByNameWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -241,7 +241,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void TrackingInformationIsEmptyForNonTrackingBranch()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -254,7 +254,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanGetTrackingInformationForTrackingBranch()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -267,7 +267,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanGetTrackingInformationForLocalTrackingBranch()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -280,7 +280,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanWalkCommitsFromAnotherBranch()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -290,7 +290,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanWalkCommitsFromBranch()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -300,8 +300,9 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("test")]
- [TestCase("refs/heads/test")]
+ [Theory]
+ [InlineData("test")]
+ [InlineData("refs/heads/test")]
public void CanCheckoutAnExistingBranch(string name)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -321,8 +322,9 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("6dcf9bf")]
- [TestCase("refs/tags/lw")]
+ [Theory]
+ [InlineData("6dcf9bf")]
+ [InlineData("refs/tags/lw")]
public void CanCheckoutAnArbitraryCommit(string commitPointer)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -348,7 +350,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CheckingOutANonExistingBranchThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -357,7 +359,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CheckingOutABranchWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -367,7 +369,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void DeletingABranchWhichIsTheCurrentHeadThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -376,7 +378,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void DeletingABranchWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -386,7 +388,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void OnlyOneBranchIsTheHead()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -408,14 +410,14 @@ namespace LibGit2Sharp.Tests
continue;
}
- Assert.Fail("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName);
+ Assert.True(false, string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
}
head.ShouldNotBeNull();
}
}
- [Test]
+ [Fact]
public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -428,7 +430,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanMoveABranch()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -444,7 +446,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void BlindlyMovingABranchOverAnExistingOneThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -453,7 +455,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanMoveABranchWhileOverwritingAnExistingOne()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
diff --git a/LibGit2Sharp.Tests/CommitFixture.cs b/LibGit2Sharp.Tests/CommitFixture.cs
index ddbc7082..c62781b2 100644
--- a/LibGit2Sharp.Tests/CommitFixture.cs
+++ b/LibGit2Sharp.Tests/CommitFixture.cs
@@ -4,17 +4,16 @@ using System.IO;
using System.Linq;
using LibGit2Sharp.Core;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class CommitFixture : BaseFixture
{
private const string sha = "8496071c1b46c854b31185ea97743be6a8774479";
private readonly List<string> expectedShas = new List<string> { "a4a7d", "c4780", "9fd73", "4a202", "5b5b0", "84960" };
- [Test]
+ [Fact]
public void CanCountCommits()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -23,7 +22,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -38,7 +37,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateCommits()
{
int count = 0;
@@ -53,7 +52,7 @@ namespace LibGit2Sharp.Tests
count.ShouldEqual(7);
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsInDetachedHeadState()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -62,13 +61,13 @@ namespace LibGit2Sharp.Tests
ObjectId parentOfHead = repo.Head.Tip.Parents.First().Id;
repo.Refs.Create("HEAD", parentOfHead.Sha, true);
- Assert.AreEqual(true, repo.Info.IsHeadDetached);
+ Assert.Equal(true, repo.Info.IsHeadDetached);
repo.Commits.Count().ShouldEqual(6);
}
}
- [Test]
+ [Fact]
public void DefaultOrderingWhenEnumeratingCommitsIsTimeBased()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -77,7 +76,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsFromSha()
{
int count = 0;
@@ -92,7 +91,7 @@ namespace LibGit2Sharp.Tests
count.ShouldEqual(6);
}
- [Test]
+ [Fact]
public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -103,7 +102,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void QueryingTheCommitHistoryFromACorruptedReferenceThrows()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -116,7 +115,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void QueryingTheCommitHistoryWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -127,7 +126,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsWithReverseTimeSorting()
{
var reversedShas = new List<string>(expectedShas);
@@ -146,7 +145,7 @@ namespace LibGit2Sharp.Tests
count.ShouldEqual(6);
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsWithReverseTopoSorting()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -158,13 +157,13 @@ namespace LibGit2Sharp.Tests
foreach (Commit p in commit.Parents)
{
Commit parent = commits.Single(x => x.Id == p.Id);
- Assert.Greater(commits.IndexOf(commit), commits.IndexOf(parent));
+ Assert.True(commits.IndexOf(commit) > commits.IndexOf(parent));
}
}
}
}
- [Test]
+ [Fact]
public void CanGetParentsCount()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -173,7 +172,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsWithTimeSorting()
{
int count = 0;
@@ -189,7 +188,7 @@ namespace LibGit2Sharp.Tests
count.ShouldEqual(6);
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsWithTopoSorting()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -201,13 +200,13 @@ namespace LibGit2Sharp.Tests
foreach (Commit p in commit.Parents)
{
Commit parent = commits.Single(x => x.Id == p.Id);
- Assert.Less(commits.IndexOf(commit), commits.IndexOf(parent));
+ Assert.True(commits.IndexOf(commit) < commits.IndexOf(parent));
}
}
}
}
- [Test]
+ [Fact]
public void CanEnumerateFromHead()
{
AssertEnumerationOfCommits(
@@ -219,7 +218,7 @@ namespace LibGit2Sharp.Tests
});
}
- [Test]
+ [Fact]
public void CanEnumerateFromDetachedHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -238,7 +237,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateUsingTwoHeadsAsBoundaries()
{
AssertEnumerationOfCommits(
@@ -247,7 +246,7 @@ namespace LibGit2Sharp.Tests
);
}
- [Test]
+ [Fact]
public void CanEnumerateUsingImplicitHeadAsSinceBoundary()
{
AssertEnumerationOfCommits(
@@ -256,7 +255,7 @@ namespace LibGit2Sharp.Tests
);
}
- [Test]
+ [Fact]
public void CanEnumerateUsingTwoAbbreviatedShasAsBoundaries()
{
AssertEnumerationOfCommits(
@@ -265,7 +264,7 @@ namespace LibGit2Sharp.Tests
);
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsFromTwoHeads()
{
AssertEnumerationOfCommits(
@@ -277,7 +276,7 @@ namespace LibGit2Sharp.Tests
});
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsFromMixedStartingPoints()
{
AssertEnumerationOfCommits(
@@ -290,13 +289,13 @@ namespace LibGit2Sharp.Tests
});
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsFromAnAnnotatedTag()
{
CanEnumerateCommitsFromATag(t => t);
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsFromATagAnnotation()
{
CanEnumerateCommitsFromATag(t => t.Annotation);
@@ -310,7 +309,7 @@ namespace LibGit2Sharp.Tests
);
}
- [Test]
+ [Fact]
public void CanEnumerateAllCommits()
{
AssertEnumerationOfCommits(
@@ -323,7 +322,7 @@ namespace LibGit2Sharp.Tests
});
}
- [Test]
+ [Fact]
public void CanEnumerateCommitsFromATagWhichDoesNotPointAtACommit()
{
AssertEnumerationOfCommits(
@@ -345,10 +344,10 @@ namespace LibGit2Sharp.Tests
IEnumerable<string> commitShas = commits.Select(c => c.Id.ToString(7)).ToArray();
- CollectionAssert.AreEqual(abbrevIds, commitShas);
+ Assert.Equal(abbrevIds, commitShas);
}
- [Test]
+ [Fact]
public void CanLookupCommitGeneric()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -360,7 +359,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanReadCommitData()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -391,7 +390,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanReadCommitWithMultipleParents()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -402,7 +401,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanDirectlyAccessABlobOfTheCommit()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -416,7 +415,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanDirectlyAccessATreeOfTheCommit()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -428,7 +427,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void DirectlyAccessingAnUnknownTreeEntryOfTheCommitReturnsNull()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -439,7 +438,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [SkippableFact]
public void CanCommitWithSignatureFromConfig()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -469,14 +468,14 @@ namespace LibGit2Sharp.Tests
var name = repo.Config.Get<string>("user.name", null);
var email = repo.Config.Get<string>("user.email", null);
- Assert.AreEqual(commit.Author.Name, name);
- Assert.AreEqual(commit.Author.Email, email);
- Assert.AreEqual(commit.Committer.Name, name);
- Assert.AreEqual(commit.Committer.Email, email);
+ Assert.Equal(commit.Author.Name, name);
+ Assert.Equal(commit.Author.Email, email);
+ Assert.Equal(commit.Committer.Name, name);
+ Assert.Equal(commit.Committer.Email, email);
}
}
- [Test]
+ [Fact]
public void CanCommitALittleBit()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -559,7 +558,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanGeneratePredictableObjectShas()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -578,7 +577,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanAmendARootCommit()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -602,7 +601,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanAmendACommitWithMoreThanOneParent()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
@@ -637,10 +636,10 @@ namespace LibGit2Sharp.Tests
headCommit.ShouldEqual(amendedCommit);
amendedCommit.Sha.ShouldNotEqual(originalCommit.Sha);
- CollectionAssert.AreEqual(originalCommit.Parents, amendedCommit.Parents);
+ Assert.Equal(originalCommit.Parents, amendedCommit.Parents);
}
- [Test]
+ [Fact]
public void CanNotAmendAnEmptyRepository()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
diff --git a/LibGit2Sharp.Tests/ConfigurationFixture.cs b/LibGit2Sharp.Tests/ConfigurationFixture.cs
index 33522129..395b4164 100644
--- a/LibGit2Sharp.Tests/ConfigurationFixture.cs
+++ b/LibGit2Sharp.Tests/ConfigurationFixture.cs
@@ -2,11 +2,10 @@
using System.IO;
using System.Text.RegularExpressions;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class ConfigurationFixture : BaseFixture
{
private static void AssertValueInLocalConfigFile(string repoPath, string regex)
@@ -19,7 +18,7 @@ namespace LibGit2Sharp.Tests
{
var text = File.ReadAllText(configFilePath);
var r = new Regex(regex, RegexOptions.Multiline).Match(text);
- Assert.IsTrue(r.Success, text);
+ Assert.True(r.Success, text);
}
private static string RetrieveGlobalConfigLocation()
@@ -51,7 +50,7 @@ namespace LibGit2Sharp.Tests
AssertValueInConfigFile(configFilePath, regex);
}
- [Test]
+ [Fact]
public void CanDeleteConfiguration()
{
var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
@@ -68,7 +67,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [SkippableFact]
public void CanGetGlobalStringValue()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -79,7 +78,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [SkippableFact]
public void CanGetGlobalStringValueWithoutRepo()
{
using (var config = new Configuration())
@@ -89,47 +88,47 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanReadBooleanValue()
{
using (var repo = new Repository(StandardTestRepoPath))
{
- Assert.IsTrue(repo.Config.Get<bool>("core.ignorecase", false));
- Assert.IsTrue(repo.Config.Get<bool>("core", "ignorecase", false));
+ Assert.True(repo.Config.Get<bool>("core.ignorecase", false));
+ Assert.True(repo.Config.Get<bool>("core", "ignorecase", false));
}
}
- [Test]
+ [Fact]
public void CanReadIntValue()
{
using (var repo = new Repository(StandardTestRepoPath))
{
- Assert.AreEqual(2, repo.Config.Get<int>("unittests.intsetting", 42));
- Assert.AreEqual(2, repo.Config.Get<int>("unittests", "intsetting", 42));
+ Assert.Equal(2, repo.Config.Get<int>("unittests.intsetting", 42));
+ Assert.Equal(2, repo.Config.Get<int>("unittests", "intsetting", 42));
}
}
- [Test]
+ [Fact]
public void CanReadLongValue()
{
using (var repo = new Repository(StandardTestRepoPath))
{
- Assert.AreEqual(15234, repo.Config.Get<long>("unittests.longsetting", 42));
- Assert.AreEqual(15234, repo.Config.Get<long>("unittests", "longsetting", 42));
+ Assert.Equal(15234, repo.Config.Get<long>("unittests.longsetting", 42));
+ Assert.Equal(15234, repo.Config.Get<long>("unittests", "longsetting", 42));
}
}
- [Test]
+ [Fact]
public void CanReadStringValue()
{
using (var repo = new Repository(StandardTestRepoPath))
{
- Assert.AreEqual("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote.origin.fetch", null));
- Assert.AreEqual("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote", "origin", "fetch", null));
+ Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote.origin.fetch", null));
+ Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote", "origin", "fetch", null));
}
}
- [Test]
+ [Fact]
public void CanSetBooleanValue()
{
var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
@@ -141,7 +140,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [SkippableFact]
public void CanSetGlobalStringValue()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -164,7 +163,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [SkippableFact]
public void CanSetGlobalStringValueWithoutRepo()
{
using(var config = new Configuration())
@@ -187,7 +186,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void SettingLocalConfigurationOutsideAReposThrows()
{
using (var config = new Configuration())
@@ -196,7 +195,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanSetIntValue()
{
var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
@@ -208,7 +207,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanSetLongValue()
{
var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
@@ -220,7 +219,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanSetStringValue()
{
var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
@@ -232,7 +231,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void ReadingUnsupportedTypeThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -242,7 +241,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void ReadingValueThatDoesntExistReturnsDefault()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -258,7 +257,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void SettingUnsupportedTypeThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
diff --git a/LibGit2Sharp.Tests/EpochFixture.cs b/LibGit2Sharp.Tests/EpochFixture.cs
index 8ef933e5..773f4c84 100644
--- a/LibGit2Sharp.Tests/EpochFixture.cs
+++ b/LibGit2Sharp.Tests/EpochFixture.cs
@@ -1,82 +1,87 @@
using System;
using LibGit2Sharp.Core;
-using NUnit.Framework;
+using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class EpochFixture
{
- [TestCase(0)]
- [TestCase(17)]
+ [Theory]
+ [InlineData(0)]
+ [InlineData(17)]
public void UnixTimestampShouldBeCastIntoAUtcBasedDateTimeOffset(long secondsSinceEpoch)
{
DateTimeOffset date = Epoch.ToDateTimeOffset(secondsSinceEpoch, 0);
- Assert.AreEqual(0, date.Offset.TotalMinutes);
+ Assert.Equal(0, date.Offset.TotalMinutes);
- Assert.AreEqual(TimeSpan.Zero, date.Offset);
- Assert.AreEqual(DateTimeKind.Utc, date.UtcDateTime.Kind);
+ Assert.Equal(TimeSpan.Zero, date.Offset);
+ Assert.Equal(DateTimeKind.Utc, date.UtcDateTime.Kind);
}
- [TestCase(0, 0)]
- [TestCase(17, -120)]
- [TestCase(31, 60)]
+ [Theory]
+ [InlineData(0, 0)]
+ [InlineData(17, -120)]
+ [InlineData(31, 60)]
public void AreEqual(long secondsSinceEpoch, int timezoneOffset)
{
DateTimeOffset one = Epoch.ToDateTimeOffset(secondsSinceEpoch, timezoneOffset);
DateTimeOffset another = Epoch.ToDateTimeOffset(secondsSinceEpoch, timezoneOffset);
- Assert.AreEqual(one, another);
- Assert.AreEqual(another, one);
+ Assert.Equal(one, another);
+ Assert.Equal(another, one);
- Assert.IsTrue(one == another);
- Assert.IsTrue(another == one);
+ Assert.True(one == another);
+ Assert.True(another == one);
- Assert.IsFalse(one != another);
- Assert.IsFalse(another != one);
+ Assert.False(one != another);
+ Assert.False(another != one);
- Assert.AreEqual(one.GetHashCode(), another.GetHashCode());
+ Assert.Equal(one.GetHashCode(), another.GetHashCode());
}
- [TestCase(1291801952, "Wed, 08 Dec 2010 09:52:32 +0000")]
- [TestCase(1234567890, "Fri, 13 Feb 2009 23:31:30 +0000")]
- [TestCase(1288114383, "Tue, 26 Oct 2010 17:33:03 +0000")]
+ [Theory]
+ [InlineData(1291801952, "Wed, 08 Dec 2010 09:52:32 +0000")]
+ [InlineData(1234567890, "Fri, 13 Feb 2009 23:31:30 +0000")]
+ [InlineData(1288114383, "Tue, 26 Oct 2010 17:33:03 +0000")]
public void UnixTimestampShouldShouldBeCastIntoAPlainUtcDate(long secondsSinceEpoch, string expected)
{
DateTimeOffset expectedDate = DateTimeOffset.Parse(expected);
DateTimeOffset date = Epoch.ToDateTimeOffset(secondsSinceEpoch, 0);
- Assert.AreEqual(secondsSinceEpoch, date.ToSecondsSinceEpoch());
- Assert.AreEqual(expectedDate, date);
- Assert.AreEqual(TimeSpan.Zero, date.Offset);
+ Assert.Equal(secondsSinceEpoch, date.ToSecondsSinceEpoch());
+ Assert.Equal(expectedDate, date);
+ Assert.Equal(TimeSpan.Zero, date.Offset);
}
- [TestCase(1250379778, -210, "Sat, 15 Aug 2009 20:12:58 -0330")]
+ [Theory]
+ [InlineData(1250379778, -210, "Sat, 15 Aug 2009 20:12:58 -0330")]
public void UnixTimestampAndTimezoneOffsetShouldBeCastIntoAUtcDateBearingAnOffset(long secondsSinceEpoch, Int32 offset, string expected)
{
DateTimeOffset expectedDate = DateTimeOffset.Parse(expected);
DateTimeOffset date = Epoch.ToDateTimeOffset(secondsSinceEpoch, offset);
- Assert.AreEqual(offset, date.Offset.TotalMinutes);
- Assert.AreEqual(secondsSinceEpoch, date.ToSecondsSinceEpoch());
+ Assert.Equal(offset, date.Offset.TotalMinutes);
+ Assert.Equal(secondsSinceEpoch, date.ToSecondsSinceEpoch());
- Assert.AreEqual(expectedDate, date);
- Assert.AreEqual(expectedDate.Offset, date.Offset);
+ Assert.Equal(expectedDate, date);
+ Assert.Equal(expectedDate.Offset, date.Offset);
}
- [TestCase("Wed, 08 Dec 2010 09:52:32 +0000", 1291801952, 0)]
- [TestCase("Fri, 13 Feb 2009 23:31:30 +0000", 1234567890, 0)]
- [TestCase("Tue, 26 Oct 2010 17:33:03 +0000", 1288114383, 0)]
- [TestCase("Sat, 14 Feb 2009 00:31:30 +0100", 1234567890, 60)]
- [TestCase("Sat, 15 Aug 2009 20:12:58 -0330", 1250379778, -210)]
- [TestCase("Sat, 15 Aug 2009 23:42:58 +0000", 1250379778, 0)]
- [TestCase("Sun, 16 Aug 2009 00:42:58 +0100", 1250379778, 60)]
+ [Theory]
+ [InlineData("Wed, 08 Dec 2010 09:52:32 +0000", 1291801952, 0)]
+ [InlineData("Fri, 13 Feb 2009 23:31:30 +0000", 1234567890, 0)]
+ [InlineData("Tue, 26 Oct 2010 17:33:03 +0000", 1288114383, 0)]
+ [InlineData("Sat, 14 Feb 2009 00:31:30 +0100", 1234567890, 60)]
+ [InlineData("Sat, 15 Aug 2009 20:12:58 -0330", 1250379778, -210)]
+ [InlineData("Sat, 15 Aug 2009 23:42:58 +0000", 1250379778, 0)]
+ [InlineData("Sun, 16 Aug 2009 00:42:58 +0100", 1250379778, 60)]
public void DateTimeOffsetShoudlBeCastIntoAUnixTimestampAndATimezoneOffset(string formattedDate, long expectedSeconds, Int32 expectedOffset)
{
DateTimeOffset when = DateTimeOffset.Parse(formattedDate);
DateTimeOffset date = Epoch.ToDateTimeOffset(expectedSeconds, expectedOffset);
- Assert.AreEqual(when, date);
+ Assert.Equal(when, date);
}
}
}
diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs
index 196df26e..f82610d0 100644
--- a/LibGit2Sharp.Tests/IndexFixture.cs
+++ b/LibGit2Sharp.Tests/IndexFixture.cs
@@ -4,11 +4,11 @@ using System.IO;
using System.Linq;
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class IndexFixture : BaseFixture
{
private static readonly string subBranchFile = Path.Combine("1", "branch_file.txt");
@@ -26,7 +26,7 @@ namespace LibGit2Sharp.Tests
"new_tracked_file.txt"
};
- [Test]
+ [Fact]
public void CanCountEntriesInIndex()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -35,16 +35,16 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateIndex()
{
using (var repo = new Repository(StandardTestRepoPath))
{
- CollectionAssert.AreEqual(expectedEntries, repo.Index.Select(e => e.Path).ToArray());
+ Assert.Equal(expectedEntries, repo.Index.Select(e => e.Path).ToArray());
}
}
- [Test]
+ [Fact]
public void CanFetchAnIndexEntryByItsName()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -62,7 +62,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void FetchingAnUnknownIndexEntryReturnsNull()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -72,7 +72,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void ReadIndexWithBadParamsFails()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -82,12 +82,13 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("1/branch_file.txt", FileStatus.Unaltered, true, FileStatus.Unaltered, true, 0)]
- [TestCase("deleted_unstaged_file.txt", FileStatus.Missing, true, FileStatus.Removed, false, -1)]
- [TestCase("modified_unstaged_file.txt", FileStatus.Modified, true, FileStatus.Staged, true, 0)]
- [TestCase("new_untracked_file.txt", FileStatus.Untracked, false, FileStatus.Added, true, 1)]
- [TestCase("modified_staged_file.txt", FileStatus.Staged, true, FileStatus.Staged, true, 0)]
- [TestCase("new_tracked_file.txt", FileStatus.Added, true, FileStatus.Added, true, 0)]
+ [Theory]
+ [InlineData("1/branch_file.txt", FileStatus.Unaltered, true, FileStatus.Unaltered, true, 0)]
+ [InlineData("deleted_unstaged_file.txt", FileStatus.Missing, true, FileStatus.Removed, false, -1)]
+ [InlineData("modified_unstaged_file.txt", FileStatus.Modified, true, FileStatus.Staged, true, 0)]
+ [InlineData("new_untracked_file.txt", FileStatus.Untracked, false, FileStatus.Added, true, 1)]
+ [InlineData("modified_staged_file.txt", FileStatus.Staged, true, FileStatus.Staged, true, 0)]
+ [InlineData("new_tracked_file.txt", FileStatus.Added, true, FileStatus.Added, true, 0)]
public void CanStage(string relativePath, FileStatus currentStatus, bool doesCurrentlyExistInTheIndex, FileStatus expectedStatusOnceStaged, bool doesExistInTheIndexOnceStaged, int expectedIndexCountVariation)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -105,7 +106,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanStageTheUpdationOfAStagedFile()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -129,8 +130,9 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("1/I-do-not-exist.txt", FileStatus.Nonexistent)]
- [TestCase("deleted_staged_file.txt", FileStatus.Removed)]
+ [Theory]
+ [InlineData("1/I-do-not-exist.txt", FileStatus.Nonexistent)]
+ [InlineData("deleted_staged_file.txt", FileStatus.Removed)]
public void StagingAnUnknownFileThrows(string relativePath, FileStatus status)
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -142,7 +144,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanStageTheRemovalOfAStagedFile()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -165,7 +167,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void StagingANewVersionOfAFileThenUnstagingItRevertsTheBlobToTheVersionOfHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -191,7 +193,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanStageANewFileInAPersistentManner()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
@@ -220,7 +222,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanStageANewFileWithAFullPath()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -239,7 +241,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorCharacters()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -262,7 +264,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void StagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -279,7 +281,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void StageFileWithBadParamsThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -291,12 +293,13 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("1/branch_file.txt", FileStatus.Unaltered, true, FileStatus.Unaltered, true, 0)]
- [TestCase("deleted_unstaged_file.txt", FileStatus.Missing, true, FileStatus.Missing, true, 0)]
- [TestCase("modified_unstaged_file.txt", FileStatus.Modified, true, FileStatus.Modified, true, 0)]
- [TestCase("new_untracked_file.txt", FileStatus.Untracked, false, FileStatus.Untracked, false, 0)]
- [TestCase("modified_staged_file.txt", FileStatus.Staged, true, FileStatus.Modified, true, 0)]
- [TestCase("new_tracked_file.txt", FileStatus.Added, true, FileStatus.Untracked, false, -1)]
+ [Theory]
+ [InlineData("1/branch_file.txt", FileStatus.Unaltered, true, FileStatus.Unaltered, true, 0)]
+ [InlineData("deleted_unstaged_file.txt", FileStatus.Missing, true, FileStatus.Missing, true, 0)]
+ [InlineData("modified_unstaged_file.txt", FileStatus.Modified, true, FileStatus.Modified, true, 0)]
+ [InlineData("new_untracked_file.txt", FileStatus.Untracked, false, FileStatus.Untracked, false, 0)]
+ [InlineData("modified_staged_file.txt", FileStatus.Staged, true, FileStatus.Modified, true, 0)]
+ [InlineData("new_tracked_file.txt", FileStatus.Added, true, FileStatus.Untracked, false, -1)]
public void CanUnStage(string relativePath, FileStatus currentStatus, bool doesCurrentlyExistInTheIndex, FileStatus expectedStatusOnceStaged, bool doesExistInTheIndexOnceStaged, int expectedIndexCountVariation)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -314,7 +317,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanUnstageTheRemovalOfAFile()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -336,7 +339,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void UnstagingFileWithBadParamsThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -348,7 +351,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanRenameAFile()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -399,10 +402,11 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("README", FileStatus.Unaltered, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
- [TestCase("new_tracked_file.txt", FileStatus.Added, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Nonexistent, FileStatus.Staged)]
- [TestCase("modified_staged_file.txt", FileStatus.Staged, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
- [TestCase("modified_unstaged_file.txt", FileStatus.Modified, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
+ [Theory]
+ [InlineData("README", FileStatus.Unaltered, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
+ [InlineData("new_tracked_file.txt", FileStatus.Added, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Nonexistent, FileStatus.Staged)]
+ [InlineData("modified_staged_file.txt", FileStatus.Staged, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
+ [InlineData("modified_unstaged_file.txt", FileStatus.Modified, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileStatus sourceStatus, string destPath, FileStatus destStatus, FileStatus sourcePostStatus, FileStatus destPostStatus)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -418,24 +422,27 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("README", FileStatus.Unaltered, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
- [TestCase("new_tracked_file.txt", FileStatus.Added, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
- [TestCase("modified_staged_file.txt", FileStatus.Staged, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
- [TestCase("modified_unstaged_file.txt", FileStatus.Modified, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ [Theory]
+ [InlineData("README", FileStatus.Unaltered, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ [InlineData("new_tracked_file.txt", FileStatus.Added, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ [InlineData("modified_staged_file.txt", FileStatus.Staged, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ [InlineData("modified_unstaged_file.txt", FileStatus.Modified, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
public void MovingOverAnExistingFileThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
{
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
}
- [TestCase("new_untracked_file.txt", FileStatus.Untracked, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ [Theory]
+ [InlineData("new_untracked_file.txt", FileStatus.Untracked, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
{
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
}
- [TestCase("deleted_unstaged_file.txt", FileStatus.Missing, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
- [TestCase("deleted_staged_file.txt", FileStatus.Removed, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
- [TestCase("i_dont_exist.txt", FileStatus.Nonexistent, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ [Theory]
+ [InlineData("deleted_unstaged_file.txt", FileStatus.Missing, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ [InlineData("deleted_staged_file.txt", FileStatus.Removed, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ [InlineData("i_dont_exist.txt", FileStatus.Nonexistent, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
{
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
@@ -455,8 +462,9 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("1/branch_file.txt", FileStatus.Unaltered, true, FileStatus.Removed)]
- [TestCase("deleted_unstaged_file.txt", FileStatus.Missing, false, FileStatus.Removed)]
+ [Theory]
+ [InlineData("1/branch_file.txt", FileStatus.Unaltered, true, FileStatus.Removed)]
+ [InlineData("deleted_unstaged_file.txt", FileStatus.Missing, false, FileStatus.Removed)]
public void CanRemoveAFile(string filename, FileStatus initialStatus, bool shouldInitiallyExist, FileStatus finalStatus)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -477,9 +485,10 @@ namespace LibGit2Sharp.Tests
}
}
- [TestCase("deleted_staged_file.txt")]
- [TestCase("modified_unstaged_file.txt")]
- [TestCase("shadowcopy_of_an_unseen_ghost.txt")]
+ [Theory]
+ [InlineData("deleted_staged_file.txt")]
+ [InlineData("modified_unstaged_file.txt")]
+ [InlineData("shadowcopy_of_an_unseen_ghost.txt")]
public void RemovingAInvalidFileThrows(string filepath)
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -488,7 +497,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void PathsOfIndexEntriesAreExpressedInNativeFormat()
{
// Initialize a new repository
diff --git a/LibGit2Sharp.Tests/LazyFixture.cs b/LibGit2Sharp.Tests/LazyFixture.cs
index f878b88b..a79ec43c 100644
--- a/LibGit2Sharp.Tests/LazyFixture.cs
+++ b/LibGit2Sharp.Tests/LazyFixture.cs
@@ -1,21 +1,20 @@
using System;
using LibGit2Sharp.Core.Compat;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class LazyFixture
{
- [Test]
+ [Fact]
public void CanReturnTheValue()
{
var lazy = new Lazy<int>(() => 2);
lazy.Value.ShouldEqual(2);
}
- [Test]
+ [Fact]
public void IsLazilyEvaluated()
{
int i = 0;
@@ -26,7 +25,7 @@ namespace LibGit2Sharp.Tests
lazy.Value.ShouldEqual(1);
}
- [Test]
+ [Fact]
public void IsEvaluatedOnlyOnce()
{
int i = 0;
diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
index 80da00cd..3fcdd12e 100644
--- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
+++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
@@ -35,11 +35,14 @@
<DocumentationFile />
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework">
- <HintPath>..\Lib\NUnit\nunit.framework.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="xunit">
+ <HintPath>..\Lib\xUnit\xunit.dll</HintPath>
+ </Reference>
+ <Reference Include="xunit.extensions">
+ <HintPath>..\Lib\xUnit\xunit.extensions.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigurationFixture.cs" />
@@ -64,6 +67,8 @@
<Compile Include="TestHelpers\IPostTestDirectoryRemover.cs" />
<Compile Include="TestHelpers\SelfCleaningDirectory.cs" />
<Compile Include="TestHelpers\SignatureExtensions.cs" />
+ <Compile Include="TestHelpers\SkipException.cs" />
+ <Compile Include="TestHelpers\SkippableFactAttribute.cs" />
<Compile Include="TestHelpers\TemporaryCloneOfTestRepo.cs" />
<Compile Include="TreeFixture.cs" />
<Compile Include="TupleFixture.cs" />
diff --git a/LibGit2Sharp.Tests/ObjectIdFixture.cs b/LibGit2Sharp.Tests/ObjectIdFixture.cs
index ebcef4d9..065e1119 100644
--- a/LibGit2Sharp.Tests/ObjectIdFixture.cs
+++ b/LibGit2Sharp.Tests/ObjectIdFixture.cs
@@ -1,26 +1,27 @@
using System;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class ObjectIdFixture
{
private const string validSha1 = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09";
private const string validSha2 = "de08fe4884650f067bd5703b6a59a8b3b3c99a09";
- [TestCase("Dummy", typeof(ArgumentException))]
- [TestCase("", typeof(ArgumentException))]
- [TestCase("8e", typeof(ArgumentException))]
- [TestCase(null, typeof(ArgumentNullException))]
- [TestCase(validSha1 + "dd", typeof(ArgumentException))]
+ [Theory]
+ [InlineData("Dummy", typeof(ArgumentException))]
+ [InlineData("", typeof(ArgumentException))]
+ [InlineData("8e", typeof(ArgumentException))]
+ [InlineData(null, typeof(ArgumentNullException))]
+ [InlineData(validSha1 + "dd", typeof(ArgumentException))]
public void PreventsFromBuildingWithAnInvalidSha(string malformedSha, Type expectedExceptionType)
{
Assert.Throws(expectedExceptionType, () => new ObjectId(malformedSha));
}
- [Test]
+ [Fact]
public void CanConvertOidToSha()
{
var bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 };
@@ -31,7 +32,7 @@ namespace LibGit2Sharp.Tests
id.ToString().ShouldEqual(validSha1);
}
- [Test]
+ [Fact]
public void CanConvertShaToOid()
{
var id = new ObjectId(validSha1);
@@ -39,7 +40,7 @@ namespace LibGit2Sharp.Tests
id.RawId.ShouldEqual(new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 });
}
- [Test]
+ [Fact]
public void CreatingObjectIdWithWrongNumberOfBytesThrows()
{
var bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154 };
@@ -47,7 +48,7 @@ namespace LibGit2Sharp.Tests
Assert.Throws<ArgumentException>(() => { new ObjectId(bytes); });
}
- [Test]
+ [Fact]
public void DifferentObjectIdsAreEqual()
{
var a = new ObjectId(validSha1);
@@ -60,7 +61,7 @@ namespace LibGit2Sharp.Tests
(a != b).ShouldBeTrue();
}
- [Test]
+ [Fact]
public void DifferentObjectIdsDoesNotHaveSameHashCode()
{
var a = new ObjectId(validSha1);
@@ -69,7 +70,7 @@ namespace LibGit2Sharp.Tests
a.GetHashCode().ShouldNotEqual(b.GetHashCode());
}
- [Test]
+ [Fact]
public void SimilarObjectIdsAreEqual()
{
var a = new ObjectId(validSha1);
@@ -82,7 +83,7 @@ namespace LibGit2Sharp.Tests
(a != b).ShouldBeFalse();
}
- [Test]
+ [Fact]
public void SimilarObjectIdsHaveSameHashCode()
{
var a = new ObjectId(validSha1);
@@ -91,16 +92,17 @@ namespace LibGit2Sharp.Tests
a.GetHashCode().ShouldEqual(b.GetHashCode());
}
- [TestCase("Dummy", false)]
- [TestCase(null, false)]
- [TestCase("", false)]
- [TestCase("0", false)]
- [TestCase("01", false)]
- [TestCase("012", false)]
- [TestCase("0123", true)]
- [TestCase("0123456", true)]
- [TestCase(validSha1 + "d", false)]
- [TestCase(validSha1, true)]
+ [Theory]
+ [InlineData("Dummy", false)]
+ [InlineData(null, false)]
+ [InlineData("", false)]
+ [InlineData("0", false)]
+ [InlineData("01", false)]
+ [InlineData("012", false)]
+ [InlineData("0123", true)]
+ [InlineData("0123456", true)]
+ [InlineData(validSha1 + "d", false)]
+ [InlineData(validSha1, true)]
public void TryParse(string maybeSha, bool isValidSha)
{
ObjectId parsedObjectId;
diff --git a/LibGit2Sharp.Tests/ReferenceFixture.cs b/LibGit2Sharp.Tests/ReferenceFixture.cs
index 0579f58a..d32da548 100644
--- a/LibGit2Sharp.Tests/ReferenceFixture.cs
+++ b/LibGit2Sharp.Tests/ReferenceFixture.cs
@@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class ReferenceFixture : BaseFixture
{
private readonly string[] expectedRefs = new[]
@@ -15,7 +14,7 @@ namespace LibGit2Sharp.Tests
"refs/heads/test", "refs/tags/e90810b", "refs/tags/lw", "refs/tags/point_to_blob", "refs/tags/test",
};
- [Test]
+ [Fact]
public void CanCreateADirectReference()
{
const string name = "refs/heads/unit_test";
@@ -33,7 +32,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateASymbolicReference()
{
const string name = "refs/heads/unit_test";
@@ -52,7 +51,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void BlindlyCreatingADirectReferenceOverAnExistingOneThrows()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -62,7 +61,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void BlindlyCreatingASymbolicReferenceOverAnExistingOneThrows()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -72,7 +71,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateAndOverwriteADirectReference()
{
const string name = "refs/heads/br2";
@@ -90,7 +89,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateAndOverwriteASymbolicReference()
{
const string name = "HEAD";
@@ -108,7 +107,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateWithEmptyStringForTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -117,7 +116,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateWithEmptyStringThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -126,7 +125,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateWithNullForTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -135,7 +134,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateWithNullStringThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -144,7 +143,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanDeleteAReference()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -154,7 +153,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void ADeletedReferenceCannotBeLookedUp()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -167,7 +166,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void DeletingAReferenceDecreasesTheRefsCount()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -187,7 +186,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void DeleteWithEmptyNameThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -196,7 +195,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void DeleteWithNullNameThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -205,7 +204,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanListAllReferencesEvenCorruptedOnes()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -213,13 +212,13 @@ namespace LibGit2Sharp.Tests
{
CreateCorruptedDeadBeefHead(repo.Info.Path);
- CollectionAssert.AreEqual(expectedRefs, repo.Refs.Select(r => r.CanonicalName).ToArray());
+ Assert.Equal(expectedRefs, repo.Refs.Select(r => r.CanonicalName).ToArray());
repo.Refs.Count().ShouldEqual(10);
}
}
- [Test]
+ [Fact]
public void CanResolveHeadByName()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -230,7 +229,7 @@ namespace LibGit2Sharp.Tests
head.Target.ShouldNotBeNull();
head.Target.CanonicalName.ShouldEqual("refs/heads/master");
head.ResolveToDirectReference().Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
- Assert.IsInstanceOf<Commit>(((DirectReference)head.Target).Target);
+ Assert.IsType<Commit>(((DirectReference)head.Target).Target);
Branch head2 = repo.Head;
head2.CanonicalName.ShouldEqual("refs/heads/master");
@@ -240,7 +239,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanResolveReferenceToALightweightTag()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -250,11 +249,11 @@ namespace LibGit2Sharp.Tests
lwTag.CanonicalName.ShouldEqual("refs/tags/lw");
lwTag.Target.ShouldNotBeNull();
lwTag.Target.Sha.ShouldEqual("e90810b8df3e80c413d903f631643c716887138d");
- Assert.IsInstanceOf<Commit>(lwTag.Target);
+ Assert.IsType<Commit>(lwTag.Target);
}
}
- [Test]
+ [Fact]
public void CanResolveReferenceToAnAnnotatedTag()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -264,11 +263,11 @@ namespace LibGit2Sharp.Tests
annTag.CanonicalName.ShouldEqual("refs/tags/test");
annTag.Target.ShouldNotBeNull();
annTag.Target.Sha.ShouldEqual("b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
- Assert.IsInstanceOf<TagAnnotation>(annTag.Target);
+ Assert.IsType<TagAnnotation>(annTag.Target);
}
}
- [Test]
+ [Fact]
public void CanResolveRefsByName()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -278,11 +277,11 @@ namespace LibGit2Sharp.Tests
master.CanonicalName.ShouldEqual("refs/heads/master");
master.Target.ShouldNotBeNull();
master.Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
- Assert.IsInstanceOf<Commit>(master.Target);
+ Assert.IsType<Commit>(master.Target);
}
}
- [Test]
+ [Fact]
public void ResolvingWithEmptyStringThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -291,7 +290,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void ResolvingWithNullThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -300,7 +299,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanUpdateTargetOnReference()
{
const string masterRef = "refs/heads/master";
@@ -320,7 +319,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanUpdateTargetOnSymbolicReference()
{
const string name = "refs/heads/unit_test";
@@ -339,7 +338,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanUpdateHeadWithEitherAnOidOrACanonicalHeadReference()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -358,7 +357,7 @@ namespace LibGit2Sharp.Tests
}
- [Test]
+ [Fact]
public void UpdatingADirectRefWithSymbolFails()
{
const string name = "refs/heads/unit_test";
@@ -375,7 +374,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void UpdatingASymbolicRefWithOidFails()
{
const string masterRef = "refs/heads/master";
@@ -385,7 +384,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void UpdatingAReferenceTargetWithBadParametersFails()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -397,7 +396,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanMoveAReferenceToADeeperReferenceHierarchy()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -411,7 +410,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanMoveAReferenceToAUpperReferenceHierarchy()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -427,7 +426,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanMoveAReferenceToADifferentReferenceHierarchy()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -441,7 +440,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void MovingANonExistingReferenceThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -450,7 +449,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanMoveAndOverWriteAExistingReference()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -466,7 +465,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void BlindlyOverwritingAExistingReferenceThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -475,7 +474,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void MovingAReferenceDoesNotDecreaseTheRefsCount()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -497,7 +496,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanLookupAMovedReference()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
diff --git a/LibGit2Sharp.Tests/RemoteFixture.cs b/LibGit2Sharp.Tests/RemoteFixture.cs
index 1f19ce15..ca721c90 100644
--- a/LibGit2Sharp.Tests/RemoteFixture.cs
+++ b/LibGit2Sharp.Tests/RemoteFixture.cs
@@ -1,12 +1,11 @@
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class RemoteFixture : BaseFixture
{
- [Test]
+ [Fact]
public void CanGetRemoteOrigin()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -18,7 +17,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void GettingRemoteThatDoesntExistReturnsNull()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -27,7 +26,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateTheRemotes()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -44,7 +43,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCheckEqualityOfRemote()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs
index 24ffbd93..077562ff 100644
--- a/LibGit2Sharp.Tests/RepositoryFixture.cs
+++ b/LibGit2Sharp.Tests/RepositoryFixture.cs
@@ -2,16 +2,15 @@
using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class RepositoryFixture : BaseFixture
{
private const string commitSha = "8496071c1b46c854b31185ea97743be6a8774479";
- [Test]
+ [Fact]
public void CanCreateBareRepo()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -30,7 +29,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateStandardRepo()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -68,7 +67,7 @@ namespace LibGit2Sharp.Tests
(attribs & FileAttributes.Hidden).ShouldEqual(FileAttributes.Hidden);
}
- [Test]
+ [Fact]
public void CanReinitARepository()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -80,7 +79,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingRepoWithBadParamsThrows()
{
Assert.Throws<ArgumentException>(() => Repository.Init(string.Empty));
@@ -115,7 +114,7 @@ namespace LibGit2Sharp.Tests
repo.Tags.Count().ShouldEqual(0);
}
- [Test]
+ [Fact]
public void CanOpenBareRepositoryThroughAFullPathToTheGitDir()
{
string path = Path.GetFullPath(BareTestRepoPath);
@@ -126,7 +125,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanOpenStandardRepositoryThroughAWorkingDirPath()
{
using (var repo = new Repository(StandardTestRepoWorkingDirPath))
@@ -136,7 +135,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void OpeningStandardRepositoryThroughTheGitDirGuessesTheWorkingDirPath()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -146,7 +145,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanOpenRepository()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -159,53 +158,53 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void OpeningNonExistentRepoThrows()
{
Assert.Throws<LibGit2Exception>(() => { new Repository("a_bad_path"); });
}
- [Test]
+ [Fact]
public void OpeningRepositoryWithBadParamsThrows()
{
Assert.Throws<ArgumentException>(() => new Repository(string.Empty));
Assert.Throws<ArgumentNullException>(() => new Repository(null));
}
- [Test]
+ [Fact]
public void CanLookupACommitByTheNameOfABranch()
{
using (var repo = new Repository(BareTestRepoPath))
{
GitObject gitObject = repo.Lookup("refs/heads/master");
gitObject.ShouldNotBeNull();
- Assert.IsInstanceOf<Commit>(gitObject);
+ Assert.IsType<Commit>(gitObject);
}
}
- [Test]
+ [Fact]
public void CanLookupACommitByTheNameOfALightweightTag()
{
using (var repo = new Repository(BareTestRepoPath))
{
GitObject gitObject = repo.Lookup("refs/tags/lw");
gitObject.ShouldNotBeNull();
- Assert.IsInstanceOf<Commit>(gitObject);
+ Assert.IsType<Commit>(gitObject);
}
}
- [Test]
+ [Fact]
public void CanLookupATagAnnotationByTheNameOfAnAnnotatedTag()
{
using (var repo = new Repository(BareTestRepoPath))
{
GitObject gitObject = repo.Lookup("refs/tags/e90810b");
gitObject.ShouldNotBeNull();
- Assert.IsInstanceOf<TagAnnotation>(gitObject);
+ Assert.IsType<TagAnnotation>(gitObject);
}
}
- [Test]
+ [Fact]
public void CanLookupObjects()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -216,7 +215,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanLookupSameObjectTwiceAndTheyAreEqual()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -228,7 +227,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void LookupObjectByWrongShaReturnsNull()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -238,7 +237,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void LookupObjectByWrongTypeReturnsNull()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -249,7 +248,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void LookupObjectByUnknownReferenceNameReturnsNull()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -259,7 +258,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanLookupWhithShortIdentifers()
{
const string expectedAbbrevSha = "edfecad";
@@ -287,7 +286,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void LookingUpWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -301,42 +300,42 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanDiscoverABareRepoGivenTheRepoPath()
{
string path = Repository.Discover(BareTestRepoPath);
path.ShouldEqual(Path.GetFullPath(BareTestRepoPath + Path.DirectorySeparatorChar));
}
- [Test]
+ [Fact]
public void CanDiscoverABareRepoGivenASubDirectoryOfTheRepoPath()
{
string path = Repository.Discover(Path.Combine(BareTestRepoPath, "objects/4a"));
path.ShouldEqual(Path.GetFullPath(BareTestRepoPath + Path.DirectorySeparatorChar));
}
- [Test]
+ [Fact]
public void CanDiscoverAStandardRepoGivenTheRepoPath()
{
string path = Repository.Discover(StandardTestRepoPath);
path.ShouldEqual(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar));
}
- [Test]
+ [Fact]
public void CanDiscoverAStandardRepoGivenASubDirectoryOfTheRepoPath()
{
string path = Repository.Discover(Path.Combine(StandardTestRepoPath, "objects/4a"));
path.ShouldEqual(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar));
}
- [Test]
+ [Fact]
public void CanDiscoverAStandardRepoGivenTheWorkingDirPath()
{
string path = Repository.Discover(StandardTestRepoWorkingDirPath);
path.ShouldEqual(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar));
}
- [Test]
+ [Fact]
public void DiscoverReturnsNullWhenNoRepoCanBeFound()
{
string path = Path.GetTempFileName();
diff --git a/LibGit2Sharp.Tests/ResetFixture.cs b/LibGit2Sharp.Tests/ResetFixture.cs
index cfe0791d..75c6b1e7 100644
--- a/LibGit2Sharp.Tests/ResetFixture.cs
+++ b/LibGit2Sharp.Tests/ResetFixture.cs
@@ -1,15 +1,16 @@
using System;
using System.IO;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
+using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class ResetFixture : BaseFixture
{
- [TestCase(true)]
- [TestCase(false)]
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
public void ResetANewlyInitializedRepositoryThrows(bool isBare)
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -20,7 +21,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void SoftResetToTheHeadOfARepositoryDoesNotChangeTheTargetOfTheHead()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -33,7 +34,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void SoftResetSetsTheHeadToTheDereferencedCommitOfAChainedTag()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -46,7 +47,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void ResettingWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -57,14 +58,14 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void SoftResetSetsTheHeadToTheSpecifiedCommit()
{
/* Make the Head point to a branch through its name */
AssertSoftReset(b => b.Name, false, b => b.Name);
}
- [Test]
+ [Fact]
public void SoftResetSetsTheDetachedHeadToTheSpecifiedCommit()
{
/* Make the Head point to a commit through its sha (Detaches the Head) */
@@ -126,7 +127,7 @@ namespace LibGit2Sharp.Tests
repo.Index.RetrieveStatus().IsDirty.ShouldBeFalse();
}
- [Test]
+ [Fact]
public void MixedResetRefreshesTheIndex()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -143,7 +144,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void MixedResetInABareRepositoryThrows()
{
using (var repo = new Repository(BareTestRepoPath))
diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs
index 8c09974b..bc7ff57b 100644
--- a/LibGit2Sharp.Tests/StatusFixture.cs
+++ b/LibGit2Sharp.Tests/StatusFixture.cs
@@ -2,13 +2,13 @@
using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
public class StatusFixture : BaseFixture
{
- [Test]
+ [Fact]
public void CanRetrieveTheStatusOfAFile()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -18,7 +18,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void RetrievingTheStatusOfADirectoryThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
@@ -27,7 +27,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanRetrieveTheStatusOfTheWholeWorkingDirectory()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -63,7 +63,7 @@ namespace LibGit2Sharp.Tests
status2.IsDirty.ShouldBeTrue();
status2.Untracked.Single().ShouldEqual("new_untracked_file.txt");
- CollectionAssert.AreEqual(new[] { file, "modified_unstaged_file.txt" }, status2.Modified);
+ Assert.Equal(new[] { file, "modified_unstaged_file.txt" }, status2.Modified);
status2.Missing.Single().ShouldEqual("deleted_unstaged_file.txt");
status2.Added.Single().ShouldEqual("new_tracked_file.txt");
status2.Staged.Single().ShouldEqual(file);
@@ -71,7 +71,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanRetrieveTheStatusOfANewRepository()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -92,7 +92,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths()
{
// Initialize a new repository
@@ -127,7 +127,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -139,7 +139,7 @@ namespace LibGit2Sharp.Tests
RepositoryStatus status = repo.Index.RetrieveStatus();
- CollectionAssert.AreEqual(new[]{relativePath, "new_untracked_file.txt"}, status.Untracked);
+ Assert.Equal(new[]{relativePath, "new_untracked_file.txt"}, status.Untracked);
string gitignorePath = Path.Combine(repo.Info.WorkingDirectory, ".gitignore");
File.WriteAllText(gitignorePath, "*.txt" + Environment.NewLine);
diff --git a/LibGit2Sharp.Tests/TagFixture.cs b/LibGit2Sharp.Tests/TagFixture.cs
index 0eb9e640..7cdbd439 100644
--- a/LibGit2Sharp.Tests/TagFixture.cs
+++ b/LibGit2Sharp.Tests/TagFixture.cs
@@ -3,11 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using LibGit2Sharp.Core;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class TagFixture : BaseFixture
{
private readonly string[] expectedTags = new[] { "e90810b", "lw", "point_to_blob", "test", };
@@ -18,7 +17,7 @@ namespace LibGit2Sharp.Tests
private const string commitE90810BSha = "e90810b8df3e80c413d903f631643c716887138d";
private const string tagE90810BSha = "7b4384978d2493e851f9cca7858815fac9b10980";
- [Test]
+ [Fact]
public void CanCreateALightWeightTagFromSha()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -30,7 +29,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateALightWeightTagFromAbbreviatedSha()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -42,7 +41,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateALightweightTagFromABranchName()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -54,7 +53,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateAndOverwriteALightweightTag()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -66,7 +65,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateATagWithNameContainingASlash()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -89,7 +88,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingATagWithNameMatchingAnAlreadyExistingReferenceHierarchyThrows()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -101,7 +100,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateAnAnnotatedTagFromABranchName()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -113,7 +112,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateAnAnnotatedTagFromSha()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -125,8 +124,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L359)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L359)
public void CanCreateAnAnnotatedTagWithAnEmptyMessage()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -139,7 +138,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateAndOverwriteAnAnnotatedTag()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -151,7 +150,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingAnAnnotatedTagIsDeterministic()
{
const string tagName = "nullTAGen";
@@ -168,8 +167,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L32)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L32)
public void CreatingATagInAEmptyRepositoryThrows()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -180,8 +179,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L37)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L37)
public void CreatingATagForHeadInAEmptyRepositoryThrows()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -192,8 +191,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L42)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L42)
public void CreatingATagForAnUnknowReferenceThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -202,7 +201,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingATagForANonCanonicalReferenceThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -211,8 +210,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L42)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L42)
public void CreatingATagForAnUnknowObjectIdThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -221,8 +220,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L48)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L48)
public void CanCreateATagForImplicitHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -238,8 +237,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L87)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L87)
public void CreatingADuplicateTagThrows()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -251,8 +250,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L90)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L90)
public void CreatingATagWithANonValidNameShouldFail()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -265,8 +264,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L101)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L101)
public void CanCreateATagUsingHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -282,7 +281,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateATagPointingToATree()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -301,7 +300,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateATagPointingToABlob()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -320,7 +319,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreatingALightweightTagPointingToATagAnnotationGeneratesAnAnnotatedTagReusingThePointedAtTagAnnotation()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -340,7 +339,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanCreateAnAnnotatedTagPointingToATagAnnotation()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -359,7 +358,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void BlindlyCreatingALightweightTagOverAnExistingOneThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -368,7 +367,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void BlindlyCreatingAnAnnotatedTagOverAnExistingOneThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -377,7 +376,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithADuplicateNameThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -386,7 +385,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithEmptyNameThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -395,7 +394,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithEmptyTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -404,7 +403,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithNotExistingTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -413,7 +412,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithNullMessageThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -422,7 +421,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithNullNameThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -431,7 +430,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithNullSignatureThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -440,7 +439,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CreateTagWithNullTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -449,7 +448,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanDeleteATagThroughItsName()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -459,7 +458,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanDeleteATagThroughItsCanonicalName()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -469,7 +468,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void ADeletedTagCannotBeLookedUp()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -482,7 +481,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void DeletingATagDecreasesTheTagsCount()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
@@ -502,8 +501,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L108)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L108)
public void DeletingAnUnknownTagShouldFail()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -512,7 +511,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void GetTagByNameWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -523,19 +522,19 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanListTags()
{
using (var repo = new Repository(BareTestRepoPath))
{
- CollectionAssert.AreEqual(expectedTags, repo.Tags.Select(t => t.Name).ToArray());
+ Assert.Equal(expectedTags, repo.Tags.Select(t => t.Name).ToArray());
repo.Tags.Count().ShouldEqual(4);
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L24)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L24)
public void CanListAllTagsInAEmptyRepository()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
@@ -547,8 +546,8 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
- [Description("Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L165)")]
+ [Fact]
+ // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L165)
public void ListAllTagsShouldOutputThemInAnOrderedWay()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -558,11 +557,11 @@ namespace LibGit2Sharp.Tests
List<string> sortedTags = expectedTags.ToList();
sortedTags.Sort();
- CollectionAssert.AreEqual(sortedTags, tagNames);
+ Assert.Equal(sortedTags, tagNames);
}
}
- [Test]
+ [Fact]
public void CanLookupALightweightTag()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -577,7 +576,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanLookupATagByItsCanonicalName()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -595,7 +594,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanLookupAnAnnotatedTag()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -615,7 +614,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void LookupEmptyTagNameThrows()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -624,7 +623,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void LookupNullTagNameThrows()
{
using (var repo = new Repository(BareTestRepoPath))
diff --git a/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs b/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs
index c8fe140d..a501d2fd 100644
--- a/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs
@@ -1,5 +1,5 @@
using System;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests.TestHelpers
{
@@ -7,46 +7,46 @@ namespace LibGit2Sharp.Tests.TestHelpers
{
public static void ShouldBeAboutEqualTo(this DateTimeOffset expected, DateTimeOffset current)
{
- Assert.AreEqual(expected.Date, current.Date);
- Assert.AreEqual(expected.Offset, current.Offset);
- Assert.AreEqual(expected.Hour, current.Hour);
- Assert.AreEqual(expected.Minute, current.Minute);
- Assert.AreEqual(expected.Second, current.Second);
+ Assert.Equal(expected.Date, current.Date);
+ Assert.Equal(expected.Offset, current.Offset);
+ Assert.Equal(expected.Hour, current.Hour);
+ Assert.Equal(expected.Minute, current.Minute);
+ Assert.Equal(expected.Second, current.Second);
}
public static void ShouldBeFalse(this bool currentObject)
{
- Assert.IsFalse(currentObject);
+ Assert.False(currentObject);
}
public static void ShouldBeNull(this object currentObject)
{
- Assert.IsNull(currentObject);
+ Assert.Null(currentObject);
}
public static void ShouldBeTrue(this bool currentObject)
{
- Assert.IsTrue(currentObject);
+ Assert.True(currentObject);
}
public static void ShouldEqual(this object compareFrom, object compareTo)
{
- Assert.AreEqual(compareTo, compareFrom);
+ Assert.Equal(compareTo, compareFrom);
}
public static void ShouldEqual<T>(this T compareFrom, T compareTo)
{
- Assert.AreEqual(compareTo, compareFrom);
+ Assert.Equal(compareTo, compareFrom);
}
public static void ShouldNotBeNull(this object currentObject)
{
- Assert.IsNotNull(currentObject);
+ Assert.NotNull(currentObject);
}
public static void ShouldNotEqual(this object compareFrom, object compareTo)
{
- Assert.AreNotEqual(compareTo, compareFrom);
+ Assert.NotEqual(compareTo, compareFrom);
}
}
}
diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index 08b5ba54..5a45fde5 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests.TestHelpers
{
- public class BaseFixture : IPostTestDirectoryRemover
+ public class BaseFixture : IPostTestDirectoryRemover, IDisposable
{
private readonly List<string> directories = new List<string>();
@@ -78,8 +78,7 @@ namespace LibGit2Sharp.Tests.TestHelpers
directories.Add(directoryPath);
}
- [TestFixtureTearDown]
- public void Cleanup()
+ public void Dispose()
{
foreach (string directory in directories)
{
@@ -94,7 +93,7 @@ namespace LibGit2Sharp.Tests.TestHelpers
return;
}
- Assert.Inconclusive(message);
+ throw new SkipException(message);
}
}
}
diff --git a/LibGit2Sharp.Tests/TestHelpers/SkipException.cs b/LibGit2Sharp.Tests/TestHelpers/SkipException.cs
new file mode 100644
index 00000000..f1df39d9
--- /dev/null
+++ b/LibGit2Sharp.Tests/TestHelpers/SkipException.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace LibGit2Sharp.Tests.TestHelpers
+{
+ class SkipException : Exception
+ {
+ public SkipException(string reason)
+ {
+ Reason = reason;
+ }
+
+ public string Reason { get; set; }
+ }
+} \ No newline at end of file
diff --git a/LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs b/LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs
new file mode 100644
index 00000000..4cd6d7a8
--- /dev/null
+++ b/LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using Xunit;
+using Xunit.Sdk;
+
+namespace LibGit2Sharp.Tests.TestHelpers
+{
+ class SkippableFactAttribute : FactAttribute
+ {
+ protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
+ {
+ yield return new SkippableTestCommand(method);
+ }
+
+ class SkippableTestCommand : FactCommand
+ {
+ public SkippableTestCommand(IMethodInfo method) : base(method) { }
+
+ public override MethodResult Execute(object testClass)
+ {
+ try
+ {
+ return base.Execute(testClass);
+ }
+ catch (SkipException e)
+ {
+ return new SkipResult(testMethod, DisplayName, e.Reason);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/LibGit2Sharp.Tests/TreeFixture.cs b/LibGit2Sharp.Tests/TreeFixture.cs
index 6e136c76..0c024e50 100755
--- a/LibGit2Sharp.Tests/TreeFixture.cs
+++ b/LibGit2Sharp.Tests/TreeFixture.cs
@@ -1,15 +1,14 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class TreeFixture : BaseFixture
{
private const string sha = "581f9824ecaf824221bd36edf5430f2739a7c4f5";
- [Test]
+ [Fact]
public void CanCompareTwoTreeEntries()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -22,7 +21,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanConvertEntryToBlob()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -35,7 +34,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanConvertEntryToTree()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -48,7 +47,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateBlobs()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -58,7 +57,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateSubTrees()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -68,7 +67,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanEnumerateTreeEntries()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -76,11 +75,11 @@ namespace LibGit2Sharp.Tests
var tree = repo.Lookup<Tree>(sha);
tree.Count().ShouldEqual(tree.Count);
- CollectionAssert.AreEqual(new[] { "1", "README", "branch_file.txt", "new.txt" }, tree.Select(te => te.Name).ToArray());
+ Assert.Equal(new[] { "1", "README", "branch_file.txt", "new.txt" }, tree.Select(te => te.Name).ToArray());
}
}
- [Test]
+ [Fact]
public void CanGetEntryByName()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -92,7 +91,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void GettingAnUknownTreeEntryReturnsNull()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -103,7 +102,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanGetEntryCountFromTree()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -113,7 +112,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanReadEntryAttributes()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -123,7 +122,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void CanReadTheTreeData()
{
using (var repo = new Repository(BareTestRepoPath))
@@ -133,7 +132,7 @@ namespace LibGit2Sharp.Tests
}
}
- [Test]
+ [Fact]
public void TreeDataIsPresent()
{
using (var repo = new Repository(BareTestRepoPath))
diff --git a/LibGit2Sharp.Tests/TupleFixture.cs b/LibGit2Sharp.Tests/TupleFixture.cs
index f909bcd0..58984b1d 100644
--- a/LibGit2Sharp.Tests/TupleFixture.cs
+++ b/LibGit2Sharp.Tests/TupleFixture.cs
@@ -1,10 +1,9 @@
using LibGit2Sharp.Core.Compat;
using LibGit2Sharp.Tests.TestHelpers;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests
{
- [TestFixture]
public class TupleFixture
{
const int integer = 2;
@@ -12,14 +11,14 @@ namespace LibGit2Sharp.Tests
private readonly Tuple<int, string> sut = new Tuple<int, string>(integer, stringy);
- [Test]
+ [Fact]
public void Properties()
{
sut.Item1.ShouldEqual(integer);
sut.Item2.ShouldEqual(stringy);
}
- [Test]
+ [Fact]
public void GetHashCodeIsTheSame()
{
var sut2 = new Tuple<int, string>(integer, stringy);
@@ -27,7 +26,7 @@ namespace LibGit2Sharp.Tests
sut.GetHashCode().ShouldEqual(sut2.GetHashCode());
}
- [Test]
+ [Fact]
public void GetHashCodeIsDifferent()
{
var sut2 = new Tuple<int, string>(integer + 1, stringy);
@@ -35,8 +34,8 @@ namespace LibGit2Sharp.Tests
sut.GetHashCode().ShouldNotEqual(sut2.GetHashCode());
}
- [Test]
- public void Equals()
+ [Fact]
+ public void VerifyEquals()
{
var sut2 = new Tuple<int, string>(integer, stringy);
@@ -44,8 +43,8 @@ namespace LibGit2Sharp.Tests
Equals(sut, sut2).ShouldBeTrue();
}
- [Test]
- public void NotEquals()
+ [Fact]
+ public void VerifyNotEquals()
{
var sut2 = new Tuple<int, string>(integer + 1, stringy);