Example #1
0
        public void TargetPathAlreadySet_DisabledUnderChangeWave16_10(string targetPath)
        {
            using TestEnvironment env = TestEnvironment.Create();
            string link = "c:/some/path";

            ChangeWaves.ResetStateForTests();
            env.SetEnvironmentVariable("MSBUILDDISABLEFEATURESFROMVERSION", ChangeWaves.Wave16_10.ToString());
            BuildEnvironmentHelper.ResetInstance_ForUnitTestsOnly();

            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            Dictionary <string, string> metaData = new Dictionary <string, string>();

            metaData.Add("TargetPath", targetPath);
            metaData.Add("Link", link);
            t.Files = new ITaskItem[]
            {
                new TaskItem(
                    itemSpec: NativeMethodsShared.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt",
                    itemMetadata: metaData)
            };
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2";

            t.Execute().ShouldBeTrue();
            t.AssignedFiles.Length.ShouldBe(1);
            t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe(link);
            ChangeWaves.ResetStateForTests();
        }
        public void AtConeRoot()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[]
            { new TaskItem(NativeMethodsShared.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt") };
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2";

            t.Execute().ShouldBeTrue();
            t.AssignedFiles.Length.ShouldBe(1);
            t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe("file.txt");
        }
        public void Regress314791()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[]
            { new TaskItem(NativeMethodsShared.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg") };
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\bin" : "/bin";

            t.Execute().ShouldBeTrue();
            t.AssignedFiles.Length.ShouldBe(1);
            t.AssignedFiles[0].ItemSpec.ShouldBe(NativeMethodsShared.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg");
            t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe("abc.efg");
        }
        public void InConeButAbsolute()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[] { new TaskItem(@"c:\f1\f2\f3\f4\file.txt") };
            t.RootFolder  = @"c:\f1\f2";

            bool success = t.Execute();

            Assert.IsTrue(success);

            Assert.AreEqual(1, t.AssignedFiles.Length);
            Assert.AreEqual(@"f3\f4\file.txt", t.AssignedFiles[0].GetMetadata("TargetPath"));
        }
        public void Regress314791()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[] { new TaskItem(@"c:\bin2\abc.efg") };
            t.RootFolder  = @"c:\bin";

            bool success = t.Execute();

            Assert.IsTrue(success);

            Assert.AreEqual(1, t.AssignedFiles.Length);
            Assert.AreEqual(@"c:\bin2\abc.efg", t.AssignedFiles[0].ItemSpec);
            Assert.AreEqual(@"abc.efg", t.AssignedFiles[0].GetMetadata("TargetPath"));
        }
Example #6
0
        public void AtConeRoot()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[]
            { new TaskItem(NativeMethodsShared.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt") };
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2";

            bool success = t.Execute();

            Assert.True(success);

            Assert.Equal(1, t.AssignedFiles.Length);
            Assert.Equal(@"file.txt", t.AssignedFiles[0].GetMetadata("TargetPath"));
        }
        public void Regress314791()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[]
            { new TaskItem(NativeMethodsShared.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg") };
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\bin" : "/bin";

            bool success = t.Execute();

            Assert.True(success);

            Assert.Single(t.AssignedFiles);
            Assert.Equal(
                NativeMethodsShared.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg",
                t.AssignedFiles[0].ItemSpec);
            Assert.Equal(@"abc.efg", t.AssignedFiles[0].GetMetadata("TargetPath"));
        }
        public void OutOfCone()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[]
            {
                new TaskItem(
                    NativeMethodsShared.IsWindows ? @"d:\f1\f2\f3\f4\file.txt" : "/f1/f2/f3/f4/file.txt")
            };
            // Create a path that's outside of the cone create above. On Windows this is achieved by
            // changing the drive letter from d:\ to c:\ to make sure the result is out of the cone.
            // If not Windows, where there is no drive, this is dine by changes the root directory from
            // /f1 to /x1
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1" : "/x1";

            t.Execute().ShouldBeTrue();
            t.AssignedFiles.Length.ShouldBe(1);
            t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe("file.txt");
        }
        public void TargetPathAlreadySet(string targetPath)
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            Dictionary <string, string> metaData = new Dictionary <string, string>();

            metaData.Add("TargetPath", targetPath);
            metaData.Add("Link", "c:/foo/bar");
            t.Files = new ITaskItem[]
            {
                new TaskItem(
                    itemSpec: NativeMethodsShared.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt",
                    itemMetadata: metaData)
            };
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2";

            t.Execute().ShouldBeTrue();
            t.AssignedFiles.Length.ShouldBe(1);
            t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe(targetPath);
        }
        public void InConeButAbsolute()
        {
            AssignTargetPath t = new AssignTargetPath();

            t.BuildEngine = new MockEngine();
            t.Files       = new ITaskItem[]
            {
                new TaskItem(
                    NativeMethodsShared.IsWindows ? @"c:\f1\f2\f3\f4\file.txt" : "/f1/f2/f3/f4/file.txt")
            };
            t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2";

            bool success = t.Execute();

            Assert.True(success);

            Assert.Single(t.AssignedFiles);
            Assert.Equal(
                NativeMethodsShared.IsWindows ? @"f3\f4\file.txt" : "f3/f4/file.txt",
                t.AssignedFiles[0].GetMetadata("TargetPath"));
        }