Exemplo n.º 1
0
        public void DeleteWithRetriesDirectoryWhichDoesntAppearsAtAll_ShouldFailWithException()
        {
            //Arrange
            const string fullTargetDirectoryPath = @"C:\Temp\xn_TestDirectoryWhichDoesntInitiallyExist";

            var task = new DeleteTree
            {
                BuildEngine = new MockBuild(),

                Retries = 10,
                RetryDelayMilliseconds = 300,

                Directories = new ITaskItem[]
                {
                    new TaskItem(fullTargetDirectoryPath)
                }
            };

            var exception = (Exception)null;

            //Act
            try
            {
                task.Execute();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            //Assert
            Assert.IsInstanceOf <DirectoryNotFoundException>(exception);
        }
Exemplo n.º 2
0
        public void DeleteWithRetriesDirectoryWhichAppearsWithDelay_ShouldSucceed()
        {
            //Arrange
            const string fullTargetDirectoryPath = @"C:\Temp\xn_TestDirectoryWhichDoesntInitiallyExist";

            var task = new DeleteTree
            {
                BuildEngine = new MockBuild(),

                Retries = 10,
                RetryDelayMilliseconds = 300,

                Directories = new ITaskItem[]
                {
                    new TaskItem(fullTargetDirectoryPath)
                }
            };

            //Act
            new Task(() =>
            {
                Thread.Sleep(2000);

                Directory.CreateDirectory(fullTargetDirectoryPath);
            }).Start();
            var result = task.Execute();

            //Assert
            Assert.IsTrue(result);
            Assert.AreEqual(1, task.DeletedDirectories.Length);
            Assert.AreEqual(fullTargetDirectoryPath, task.DeletedDirectories.FirstOrDefault().ItemSpec);
        }
Exemplo n.º 3
0
        public void ExecuteItemWithTrailingSeparator()
        {
            DeleteTree task = new DeleteTree();
            task.BuildEngine = new MockBuild();
            task.Directories = new ITaskItem[] { new TaskItem(@"..\..\..\**\obj\") };
            bool result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 4
0
        public void ExecuteInnerRecursive()
        {
            DeleteTree task = new DeleteTree();
            task.BuildEngine = new MockBuild();
            task.Directories = new ITaskItem[] { new TaskItem(@"..\..\..\**\obj") };
            bool result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 5
0
        public void MatchDirectoriesRelativeWildCard()
        {
            var path = DeleteTree.MatchDirectories(@"..\..\..\MSBuild.Community.*\**\obj");

            Assert.Greater(path.Count, 0);

            path = DeleteTree.MatchDirectories(@"..\..\..\MSBuild.*.Tests\**\obj\**");
            Assert.Greater(path.Count, 0);
        }
Exemplo n.º 6
0
        public void ExecuteItemWithTrailingSeparator()
        {
            DeleteTree task = new DeleteTree();

            task.BuildEngine = new MockBuild();
            task.Directories = new ITaskItem[] { new TaskItem(@"..\..\..\**\obj\") };
            bool result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 7
0
        public void ExecuteInnerRecursive()
        {
            DeleteTree task = new DeleteTree();

            task.BuildEngine = new MockBuild();
            task.Directories = new ITaskItem[] { new TaskItem(@"..\..\..\**\obj") };
            bool result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 8
0
        public void ExecuteWildCard()
        {
            DeleteTree task = new DeleteTree();
            task.BuildEngine = new MockBuild();
            task.Directories = new ITaskItem[]
                                   {
                                       new TaskItem(@"..\..\..\MSBuild.Community.*\**\obj"),
                                       new TaskItem(@"..\..\..\**\b?n")
                                   };

            bool result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 9
0
        public void ExecuteWildCard()
        {
            DeleteTree task = new DeleteTree();

            task.BuildEngine = new MockBuild();
            task.Directories = new ITaskItem[]
            {
                new TaskItem(@"..\..\..\MSBuild.Community.*\**\obj"),
                new TaskItem(@"..\..\..\**\b?n")
            };

            bool result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 10
0
        public void ExecuteInnerAndTrailingRecursive()
        {
            var task = new DeleteTree
            {
                BuildEngine = new MockBuild(),
                Directories = new ITaskItem[]
                {
                    new TaskItem(@"..\..\..\**\obj\**")
                }
            };

            var result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 11
0
        public void ExecuteMultipleItems()
        {
            var task = new DeleteTree
            {
                BuildEngine = new MockBuild(),
                Directories = new ITaskItem[]
                {
                    new TaskItem(@"..\..\..\**\obj"),
                    new TaskItem(@"..\..\..\**\bin")
                }
            };

            var result = task.Execute();

            Assert.IsTrue(result);
        }
Exemplo n.º 12
0
        public void MatchDirectoriesInnerRelative()
        {
            var path = DeleteTree.MatchDirectories(@"..\..\..\**\obj");

            Assert.Greater(path.Count, 0);
        }
Exemplo n.º 13
0
        public void MatchDirectoriesNoWildCards()
        {
            var path = DeleteTree.MatchDirectories(@"..\..\..");

            Assert.AreEqual(1, path.Count);
        }