Beispiel #1
0
 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);
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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"));
 }
Beispiel #4
0
 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"));
 }
Beispiel #5
0
 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);
 }
Beispiel #6
0
 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);
 }
Beispiel #7
0
 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);
 }
Beispiel #8
0
 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);
 }