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
        }
Beispiel #2
0
        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);
        }
Beispiel #4
0
        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.True(success);
            Assert.Single(t.InPath);
            Assert.Single(t.OutOfPath);
            Assert.Equal(FileUtilities.FixFilePath(@"C:\MyProject\File1.txt"), t.InPath[0].ItemSpec);
            Assert.Equal(FileUtilities.FixFilePath(@"C:\SomeoneElsesProject\File2.txt"), t.OutOfPath[0].ItemSpec);
        }
Beispiel #5
0
        public void InvalidPath()
        {
            if (!NativeMethodsShared.IsWindows)
            {
                return; // "Cannot have invalid characters in file name on Unix"
            }

            FindUnderPath t = new FindUnderPath();

            t.BuildEngine = new MockEngine();

            t.Path  = new TaskItem(@"||::||");
            t.Files = new ITaskItem[] { new TaskItem(@"foo") };

            bool success = t.Execute();

            Assert.False(success);

            // Don't crash
        }
        // 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);
            }
        }