public void InvalidPath() { FindUnderPath t = new FindUnderPath(); t.BuildEngine = new MockEngine(); t.Path = new TaskItem(@"||::||"); t.Files = new ITaskItem[] { new TaskItem(@"foo") }; bool success = t.Execute(); Assert.IsTrue(!success); // Don't crash }
public void InvalidFile() { FindUnderPath t = new FindUnderPath(); t.BuildEngine = new MockEngine(); t.Path = new TaskItem(@"C:\MyProject"); t.Files = new ITaskItem[] { new TaskItem(@":::") }; bool success = t.Execute(); Assert.False(success); // Don't crash }
public void BasicFilter() { FindUnderPath t = new FindUnderPath(); t.BuildEngine = new MockEngine(); t.Path = new TaskItem(@"C:\MyProject"); t.Files = new ITaskItem[] { new TaskItem(@"C:\MyProject\File1.txt"), new TaskItem(@"C:\SomeoneElsesProject\File2.txt") }; bool success = t.Execute(); Assert.IsTrue(success); Assert.AreEqual(1, t.InPath.Length); Assert.AreEqual(1, t.OutOfPath.Length); Assert.AreEqual(@"C:\MyProject\File1.txt", t.InPath[0].ItemSpec); Assert.AreEqual(@"C:\SomeoneElsesProject\File2.txt", t.OutOfPath[0].ItemSpec); }
// Create a temporary file and run the task on it private static void RunTask(FindUnderPath t, out FileInfo testFile, out bool success) { string fileName = ObjectModelHelpers.CreateFileInTempProjectDirectory("file%3b.temp", "foo"); testFile = new FileInfo(fileName); t.Path = new TaskItem(ObjectModelHelpers.TempProjectDir); t.Files = new ITaskItem[] { new TaskItem(EscapingUtilities.Escape(testFile.Name)), new TaskItem(@"C:\SomeoneElsesProject\File2.txt") }; success = false; string currentDirectory = Directory.GetCurrentDirectory(); try { Directory.SetCurrentDirectory(ObjectModelHelpers.TempProjectDir); success = t.Execute(); } finally { Directory.SetCurrentDirectory(currentDirectory); } }