Esempio n. 1
0
        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";

            t.Execute().ShouldBeTrue();
            t.AssignedFiles.Length.ShouldBe(1);
            t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe(NativeMethodsShared.IsWindows ? @"f3\f4\file.txt" : "f3/f4/file.txt");
        }
Esempio n. 2
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"));
        }
Esempio n. 3
0
        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.True(success);

            Assert.Equal(1, t.AssignedFiles.Length);
            Assert.Equal(@"c:\bin2\abc.efg", t.AssignedFiles[0].ItemSpec);
            Assert.Equal(@"abc.efg", 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"));
        }