From 84aa95e5e0a795df8c5e387e6efd48cdbaecb231 Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Tue, 14 Jan 2014 15:55:50 -0500 Subject: [PATCH] Capture the current handling of renames and ignore rules. --- GitTfsTest/Core/ChangeSieveTests.cs | 62 ++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/GitTfsTest/Core/ChangeSieveTests.cs b/GitTfsTest/Core/ChangeSieveTests.cs index 18c191db..cc90ab49 100644 --- a/GitTfsTest/Core/ChangeSieveTests.cs +++ b/GitTfsTest/Core/ChangeSieveTests.cs @@ -61,6 +61,7 @@ namespace Sep.Git.Tfs.Test.Core { protected readonly FixtureClass Fixture; protected ChangeSieve Subject { get { return Fixture.Subject; } } + protected IChange[] Changes { get { return Fixture.Changeset.Changes; } } public Base() { @@ -183,7 +184,6 @@ namespace Sep.Git.Tfs.Test.Core } } - [Trait("focus", "true")] public class WithAddsAndDeletes : Base { public class Fixture : BaseFixture @@ -199,10 +199,10 @@ namespace Sep.Git.Tfs.Test.Core }; Remote.Stub(r => r.GetPathInGitRepo(null)) .Constraints(Is.Anything()) - .Do((Function)delegate(string path) { return path.Replace("$/Project/", ""); }); - Remote.Stub(r => r.ShouldSkip(null)). - Constraints(Is.Anything()). - Return(false); + .Do(new Function(path => path.Replace("$/Project/", ""))); + Remote.Stub(r => r.ShouldSkip(null)) + .Constraints(Is.Anything()) + .Return(false); } } @@ -231,5 +231,57 @@ namespace Sep.Git.Tfs.Test.Core }, toApply.Select(change => change.Item.ServerItem).ToArray()); } } + + public class WithIgnoredThings : Base + { + public class Fixture : BaseFixture + { + public Fixture() + { + Changeset.Changes = new IChange[] { + FakeChange.Add("$/Project/0-ignored.txt"), + FakeChange.Delete("$/Project/1-ignored.txt"), + FakeChange.Add("$/Project/2-included.txt"), + FakeChange.Delete("$/Project/3-included.txt"), + FakeChange.Rename("$/Project/4-ignored.txt", from: "$/Project/4-wasignored.txt"), + FakeChange.Rename("$/Project/5-ignored.txt", from: "$/Project/5-wasincluded.txt"), + FakeChange.Rename("$/Project/6-included.txt", from: "$/Project/6-wasignored.txt"), + }; + Remote.Stub(r => r.GetPathInGitRepo(null)) + .Constraints(Is.Anything()) + .Do(new Function(path => path.Replace("$/Project/", ""))); + Remote.Stub(r => r.ShouldSkip(null)) + .Constraints(Is.Anything()) + .Do(new Function(s => s.Contains("ignored"))); + } + } + + [Fact] + public void HasChanges() + { + Assert.True(Subject.HasChanges()); + } + + [Fact] + public void FetchesAllExceptIgnored() + { + var fetchChanges = Subject.ChangesToFetch().ToArray(); + Assert.Equal(3, fetchChanges.Length); + Assert.Contains(Changes[2], fetchChanges); + Assert.Contains(Changes[3], fetchChanges); + Assert.Contains(Changes[6], fetchChanges); + } + + [Fact] + public void AppliesDeletesFirst() + { + var toApply = Subject.ChangesToApply(); + Assert.Equal(new string [] { + "$/Project/3-included.txt", + "$/Project/6-included.txt", + "$/Project/2-included.txt", + }, toApply.Select(change => change.Item.ServerItem).ToArray()); + } + } } }