Skip to content

Commit 674c854

Browse files
author
J Wyman
committed
Changed two RebaseFixture tests from Fact to Theory to support testing multiple .gitattribute values
1 parent b73c9ef commit 674c854

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

LibGit2Sharp.Tests/RebaseFixture.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,18 @@ int IEqualityComparer<CompletedRebaseStepInfo>.GetHashCode(CompletedRebaseStepIn
190190
/// <summary>
191191
/// Verify a single rebase, but in more detail.
192192
/// </summary>
193-
[Fact]
194-
public void VerifyRebaseDetailed()
193+
[Theory]
194+
[InlineData("* text=auto", new[] { "2cad6e96a0028f1764dcbde6292a9a1471acb114", "18fd3deebe6124b5dacc8426d589d617a968e8d1", "048977d8cb90d530e83cc615a17a49f3068f68c1" })]
195+
[InlineData("* text=lf", new[] { "4f813f70525a6ba4ea414a54ad89412b8d9f25aa", "6a2261c0739058ac987f1fa0014946753161b167", "6aa53c88fc1e739678749dff5acf4b00799b5c4d" })]
196+
[InlineData("* text=crlf", new[] { "28e48a7c129e1025d0233cb5a92425f12f55070b", "d737950e62ec31a25afc34b06075e144b3d2be31", "bf4ed0456e4a2cc42a8746191501d8521cfad6a8" })]
197+
public void VerifyRebaseDetailed(string attributes, string[] expectedIds)
195198
{
196199
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
197200
var path = Repository.Init(scd.DirectoryPath);
198201

199202
using (Repository repo = new Repository(path))
200203
{
201-
ConstructRebaseTestRepository(repo);
204+
ConstructRebaseTestRepository(repo, attributes);
202205

203206
Branch initialBranch = repo.Branches[topicBranch1Name];
204207
Branch upstreamBranch = repo.Branches[masterBranch2Name];
@@ -262,9 +265,9 @@ public void VerifyRebaseDetailed()
262265

263266
List<ObjectId> expectedTreeIds = new List<ObjectId>()
264267
{
265-
new ObjectId("2cad6e96a0028f1764dcbde6292a9a1471acb114"),
266-
new ObjectId("18fd3deebe6124b5dacc8426d589d617a968e8d1"),
267-
new ObjectId("048977d8cb90d530e83cc615a17a49f3068f68c1"),
268+
new ObjectId(expectedIds[0]),
269+
new ObjectId(expectedIds[1]),
270+
new ObjectId(expectedIds[2]),
268271
};
269272

270273
List<Commit> rebasedCommits = repo.Commits.QueryBy(commitFilter).ToList();
@@ -591,14 +594,17 @@ public void CurrentStepInfoIsNullWhenNotRebasing()
591594
}
592595
}
593596

594-
[Fact]
595-
public void CanRebaseHandlePatchAlreadyApplied()
597+
[Theory]
598+
[InlineData("* text=auto", "379e80ed7824be7672e1e30ddd8f44aa081d57d4")]
599+
[InlineData("* text=lf", "d43f4f2cb680ea446aef98f650a391224b18d171")]
600+
[InlineData("* text=crlf", "62b1e8ddefb3a083f3c6bbda138271b878c59459")]
601+
public void CanRebaseHandlePatchAlreadyApplied(string attributes, string expectedShaText)
596602
{
597603
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
598604
var path = Repository.Init(scd.DirectoryPath);
599605
using (Repository repo = new Repository(path))
600606
{
601-
ConstructRebaseTestRepository(repo);
607+
ConstructRebaseTestRepository(repo, attributes);
602608

603609
repo.Checkout(topicBranch1Name);
604610

@@ -631,7 +637,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
631637
};
632638

633639
repo.Rebase.Start(null, upstreamBranch, null, Constants.Identity2, options);
634-
ObjectId secondCommitExpectedTreeId = new ObjectId("379e80ed7824be7672e1e30ddd8f44aa081d57d4");
640+
ObjectId secondCommitExpectedTreeId = new ObjectId(expectedShaText);
635641
Signature secondCommitAuthorSignature = Constants.Signature;
636642
Identity secondCommitCommiterIdentity = Constants.Identity2;
637643

@@ -642,7 +648,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
642648
Assert.NotNull(rebaseResults[1].Commit);
643649

644650
// This is the expected tree ID of the new commit.
645-
Assert.True(ObjectId.Equals(secondCommitExpectedTreeId, rebaseResults[1].Commit.Tree.Id));
651+
Assert.Equal(secondCommitExpectedTreeId, rebaseResults[1].Commit.Tree.Id);
646652
Assert.True(Signature.Equals(secondCommitAuthorSignature, rebaseResults[1].Commit.Author));
647653
Assert.Equal<string>(secondCommitCommiterIdentity.Name, rebaseResults[1].Commit.Committer.Name, StringComparer.Ordinal);
648654
Assert.Equal<string>(secondCommitCommiterIdentity.Email, rebaseResults[1].Commit.Committer.Email, StringComparer.Ordinal);
@@ -664,7 +670,7 @@ public void RebasingInBareRepositoryThrows()
664670
}
665671
}
666672

667-
private void ConstructRebaseTestRepository(Repository repo)
673+
private void ConstructRebaseTestRepository(Repository repo, string attributes = "* text=auto")
668674
{
669675
// Constructs a graph that looks like:
670676
// * -- * -- * (modifications to c.txt)
@@ -700,7 +706,7 @@ private void ConstructRebaseTestRepository(Repository repo)
700706
string workdir = repo.Info.WorkingDirectory;
701707
Commit commit = null;
702708

703-
CreateAttributesFile(repo, "* text=auto");
709+
CreateAttributesFile(repo, attributes);
704710

705711
repo.Stage(".gitattributes");
706712
commit = repo.Commit("setup", Constants.Signature, Constants.Signature, new CommitOptions());

0 commit comments

Comments
 (0)