public void FoundCaseInsensitive() { FindInList f = new FindInList(); f.BuildEngine = new MockEngine(); f.ItemSpecToFind = "a.cs"; f.List = new ITaskItem[] { new TaskItem("A.CS"), new TaskItem("b.cs") }; Assert.True(f.Execute()); Assert.Equal("A.CS", f.ItemFound.ItemSpec); }
public void NotFoundCaseSensitive() { FindInList f = new FindInList(); f.BuildEngine = new MockEngine(); f.ItemSpecToFind = "a.cs"; f.CaseSensitive = true; f.List = new ITaskItem[] { new TaskItem("A.CS"), new TaskItem("b.cs") }; Assert.IsTrue(f.Execute()); Assert.AreEqual(null, f.ItemFound); }
public void ReturnsFirstOne() { FindInList f = new FindInList(); f.BuildEngine = new MockEngine(); f.ItemSpecToFind = "a.cs"; ITaskItem item1 = new TaskItem("a.cs"); item1.SetMetadata("id", "1"); ITaskItem item2 = new TaskItem("a.cs"); item2.SetMetadata("id", "2"); f.List = new ITaskItem[] { item1, item2 }; Assert.True(f.Execute()); Assert.Equal("a.cs", f.ItemFound.ItemSpec); Assert.Equal(item1.GetMetadata("id"), f.ItemFound.GetMetadata("id")); }
public void ReturnsLastOne() { FindInList f = new FindInList(); f.BuildEngine = new MockEngine(); f.ItemSpecToFind = "a.cs"; f.FindLastMatch = true; ITaskItem item1 = new TaskItem("a.cs"); item1.SetMetadata("id", "1"); ITaskItem item2 = new TaskItem("a.cs"); item2.SetMetadata("id", "2"); f.List = new ITaskItem[] { item1, item2 }; Assert.IsTrue(f.Execute(), "Expect success"); Assert.AreEqual("a.cs", f.ItemFound.ItemSpec); Assert.AreEqual(item2.GetMetadata("id"), f.ItemFound.GetMetadata("id")); }
public void NotFound() { FindInList f = new FindInList(); f.BuildEngine = new MockEngine(); f.ItemSpecToFind = "a.cs"; f.List = new ITaskItem[] { new TaskItem("foo\a.cs"), new TaskItem("b.cs") }; Assert.True(f.Execute()); Assert.Equal(null, f.ItemFound); }
public void ReturnsLastOneEmptyList() { FindInList f = new FindInList(); f.BuildEngine = new MockEngine(); f.ItemSpecToFind = "a.cs"; f.FindLastMatch = true; f.List = new ITaskItem[] { }; Assert.True(f.Execute()); Assert.Equal(null, f.ItemFound); }
public void MatchFileNameOnlyWithAnInvalidPath() { FindInList f = new FindInList(); MockEngine e = new MockEngine(); f.BuildEngine = e; f.ItemSpecToFind = "a.cs"; f.MatchFileNameOnly = true; f.List = new ITaskItem[] { new TaskItem(@"!@#$@$%|"), new TaskItem(@"foo\a.cs"), new TaskItem("b.cs") }; Assert.True(f.Execute()); Console.WriteLine(e.Log); // Should ignore the invalid paths Assert.Equal(@"foo\a.cs", f.ItemFound.ItemSpec); }
public void MatchFileNameOnly() { FindInList f = new FindInList(); f.BuildEngine = new MockEngine(); f.ItemSpecToFind = "a.cs"; f.MatchFileNameOnly = true; f.List = new ITaskItem[] { new TaskItem(@"c:\foo\a.cs"), new TaskItem("b.cs") }; Assert.True(f.Execute()); Assert.Equal(@"c:\foo\a.cs", f.ItemFound.ItemSpec); }