Example #1
0
        public void AbsolutePath()
        {
            string   fileName = ObjectModelHelpers.CreateFileInTempProjectDirectory("file.temp", "foo");
            FileInfo testFile = new FileInfo(fileName);

            ConvertToAbsolutePath t = new ConvertToAbsolutePath();

            t.BuildEngine = new MockEngine();

            string currentDirectory = Directory.GetCurrentDirectory();

            try
            {
                Directory.SetCurrentDirectory(ObjectModelHelpers.TempProjectDir);
                t.Paths = new ITaskItem[] { new TaskItem(fileName) };
                Assert.True(t.Execute()); // "success"
            }
            finally
            {
                Directory.SetCurrentDirectory(currentDirectory);
            }

            Assert.Single(t.AbsolutePaths);
            Assert.Equal(testFile.FullName, t.AbsolutePaths[0].ItemSpec);

            ObjectModelHelpers.DeleteTempProjectDirectory();
        }
        public void RelativePathWithEscaping()
        {
            string   fileName = ObjectModelHelpers.CreateFileInTempProjectDirectory("file%3A.temp", "foo");
            FileInfo testFile = new FileInfo(fileName);

            ConvertToAbsolutePath t = new ConvertToAbsolutePath();

            t.BuildEngine = new MockEngine();

            string currentDirectory = Directory.GetCurrentDirectory();

            try
            {
                Directory.SetCurrentDirectory(ObjectModelHelpers.TempProjectDir);
                t.Paths = new ITaskItem[] { new TaskItem(@"file%253A.temp") };
                Assert.IsTrue(t.Execute(), "success");
            }
            finally
            {
                Directory.SetCurrentDirectory(currentDirectory);
            }

            Assert.AreEqual(1, t.AbsolutePaths.Length);
            Assert.AreEqual(testFile.FullName, t.AbsolutePaths[0].ItemSpec);

            ObjectModelHelpers.DeleteTempProjectDirectory();
        }
Example #3
0
        public void FakeFile()
        {
            ConvertToAbsolutePath t = new ConvertToAbsolutePath();

            t.BuildEngine = new MockEngine();

            t.Paths = new ITaskItem[] { new TaskItem("RandomFileThatDoesntExist.txt") };

            Assert.True(t.Execute()); // "success"

            Assert.Single(t.AbsolutePaths);
        }
        public void FakeFile()
        {
            ConvertToAbsolutePath t = new ConvertToAbsolutePath();

            t.BuildEngine = new MockEngine();

            t.Paths = new ITaskItem[] { new TaskItem("RandomFileThatDoesntExist.txt") };

            Assert.IsTrue(t.Execute(), "success");

            Assert.AreEqual(1, t.AbsolutePaths.Length);
        }