Пример #1
0
        public void ExecuteWillCreateANewDirectory()
        {
            var workingDir = "workingDir\\NDependResults";
            var result = GenerateResultMock();
            var executor = GenerateExecutorMock("workingDir\\NDepend.Console", "workingDir\\NDependResults /OutDir workingDir\\NDependResults", "workingDir", 600000);
            var fileSystem = mocks.StrictMock<IFileSystem>();
            Expect.Call(fileSystem.DirectoryExists(workingDir)).Return(true).Repeat.Times(2);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[0]);
            Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\ReportResources.xml")).Return(false);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[] {
                "workingDir\\NDependResults\\file1.txt",
                "workingDir\\NDependResults\\file2.xml"
            });
            Expect.Call(fileSystem.DirectoryExists("artefactDir\\1\\NDepend")).Return(false);
            Expect.Call(() => fileSystem.CreateDirectory("artefactDir\\1\\NDepend"));
            Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\file1.txt")).Return(true);
            Expect.Call(() => fileSystem.Copy("workingDir\\NDependResults\\file1.txt", "artefactDir\\1\\NDepend\\file1.txt"));
            Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\file2.xml")).Return(true);
            Expect.Call(() => fileSystem.Copy("workingDir\\NDependResults\\file2.xml", "artefactDir\\1\\NDepend\\file2.xml"));
            Expect.Call(fileSystem.GenerateTaskResultFromFile("workingDir\\NDependResults\\file2.xml")).Return(mocks.DynamicMock<ITaskResult>());
            var logger = mocks.DynamicMock<ILogger>();
            var task = new NDependTask(executor, fileSystem, logger);

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
Пример #2
0
        public void AllApplicationArgsAreSet()
        {
            var workingDir = "workingDir\\out-dir";
            var result = GenerateResultMock();
            var executor = GenerateExecutorMock("workingDir\\NDepend.Console",
                "workingDir\\test.project /Silent /EmitVisualNDependBinXml  /InDirs workingDir\\dir1 workingDir\\dir2 /OutDir workingDir\\out-dir /XslForReport  workingDir\\report.xslt",
                "workingDir", 600000);
            var fileSystem = mocks.StrictMock<IFileSystem>();
            Expect.Call(fileSystem.DirectoryExists(workingDir)).Return(true).Repeat.Times(2);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[0]);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[] {
                "workingDir\\file1.txt",
                "workingDir\\file2.xml"
            });
            Expect.Call(() => fileSystem.EnsureFolderExists("artefactDir\\1\\NDepend"));
            Expect.Call(() => fileSystem.Copy("workingDir\\file1.txt", "artefactDir\\1\\NDepend\\file1.txt"));
            Expect.Call(() => fileSystem.Copy("workingDir\\file2.xml", "artefactDir\\1\\NDepend\\file2.xml"));
            Expect.Call(fileSystem.GenerateTaskResultFromFile("workingDir\\file2.xml")).Return(mocks.DynamicMock<ITaskResult>());
            var logger = mocks.DynamicMock<ILogger>();
            var task = new NDependTask(executor, fileSystem, logger);
            task.ProjectFile = "test.project";
            task.Silent = true;
            task.EmitXml = true;
            task.InputDirs = new string[]
            {
                "dir1",
                "dir2"
            };
            task.OutputDir = "out-dir";
            task.ReportXslt = "report.xslt";

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
Пример #3
0
 public void DefaultConstructorSetsFileSystemAndLogger()
 {
     var task = new NDependTask();
     Assert.IsInstanceOf<SystemIoFileSystem>(task.FileSystem);
     Assert.IsInstanceOf<DefaultLogger>(task.Logger);
 }
Пример #4
0
        public void RunningOnExistingDirectoryChecksFilesAndCopiesWhenNewer()
        {
            var workingDir = "workingDir\\NDependResults";
            var result = GenerateResultMock();
            var executor = GenerateExecutorMock("workingDir\\NDepend.Console", "workingDir\\NDependResults /OutDir workingDir\\NDependResults", "workingDir", 600000);
            var fileSystem = mocks.StrictMock<IFileSystem>();
            Expect.Call(fileSystem.DirectoryExists(workingDir)).Return(true).Repeat.Times(2);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[] {
                "workingDir\\NDependResults\\file1.txt",
                "workingDir\\NDependResults\\file2.xml"
            });
            Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\ReportResources.xml")).Return(false);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[] {
                "workingDir\\NDependResults\\file1.txt",
                "workingDir\\NDependResults\\file2.xml"
            });
            Expect.Call(fileSystem.DirectoryExists("artefactDir\\1\\NDepend")).Return(true);
            Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\file1.txt")).Return(true);
            Expect.Call(() => fileSystem.Copy("workingDir\\NDependResults\\file1.txt", "artefactDir\\1\\NDepend\\file1.txt"));
            var baseTime = DateTime.Now;
            Expect.Call(fileSystem.GetLastWriteTime("workingDir\\NDependResults\\file1.txt")).Return(baseTime);
            Expect.Call(fileSystem.GetLastWriteTime("workingDir\\NDependResults\\file2.xml")).Return(baseTime).Repeat.Times(2);
            Expect.Call(fileSystem.GetLastWriteTime("workingDir\\NDependResults\\file1.txt")).Return(baseTime.AddMinutes(1));
            var logger = mocks.DynamicMock<ILogger>();
            var task = new NDependTask(executor, fileSystem, logger);

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
Пример #5
0
        public void ExecuteLoadsContentsFileIfItExistsAndImportsDirectory()
        {
            var workingDir = "workingDir\\NDependResults";
            var result = GenerateResultMock();
            var executor = GenerateExecutorMock("workingDir\\NDepend.Console", "workingDir\\NDependResults /OutDir workingDir\\NDependResults", "workingDir", 600000);
            var fileSystem = mocks.StrictMock<IFileSystem>();
            Expect.Call(fileSystem.DirectoryExists(workingDir)).Return(true);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[0]);
            Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\ReportResources.xml")).Return(true);
            using (var reader = new StringReader("<ReportResources><Directory>images</Directory></ReportResources>"))
            {
                Expect.Call(fileSystem.Load("workingDir\\NDependResults\\ReportResources.xml")).Return(reader);
                Expect.Call(fileSystem.GetFilesInDirectory("workingDir\\NDependResults\\images", true)).Return(new[] { "workingDir\\NDependResults\\images\\test.png" });
                Expect.Call(fileSystem.DirectoryExists("artefactDir\\1\\NDepend\\images")).Return(false);
                Expect.Call(() => fileSystem.CreateDirectory("artefactDir\\1\\NDepend\\images"));
                Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\images\\test.png")).Return(true);
                Expect.Call(() => fileSystem.Copy("workingDir\\NDependResults\\images\\test.png", "artefactDir\\1\\NDepend\\images\\test.png"));
                var logger = mocks.DynamicMock<ILogger>();
                var task = new NDependTask(executor, fileSystem, logger);

                Expect.Call(result.Status).PropertyBehavior();
                mocks.ReplayAll();
                result.Status = IntegrationStatus.Unknown;
                task.Run(result);
                mocks.VerifyAll();
            }
        }
Пример #6
0
        public void ExecuteFailsIfContentFileIsInvalid()
        {
            var workingDir = "workingDir\\NDependResults";
            var result = GenerateResultMock();
            var executor = GenerateExecutorMock("workingDir\\NDepend.Console", "workingDir\\NDependResults /OutDir workingDir\\NDependResults", "workingDir", 600000);
            var fileSystem = mocks.StrictMock<IFileSystem>();
            Expect.Call(fileSystem.DirectoryExists(workingDir)).Return(true);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[0]);
            Expect.Call(fileSystem.FileExists("workingDir\\NDependResults\\ReportResources.xml")).Return(true);
            using (var reader = new StringReader("garbage"))
            {
                Expect.Call(fileSystem.Load("workingDir\\NDependResults\\ReportResources.xml")).Return(reader);
                var logger = mocks.DynamicMock<ILogger>();
                var task = new NDependTask(executor, fileSystem, logger);

                Expect.Call(result.Status).PropertyBehavior();
                mocks.ReplayAll();
                result.Status = IntegrationStatus.Unknown;
                Assert.Throws<CruiseControlException>(() => task.Run(result));
                mocks.VerifyAll();
            }
        }
Пример #7
0
        public void CanOverrideExecutable()
        {
            var workingDir = "workingDir\\NDependResults";
            var result = GenerateResultMock();
            var executor = GenerateExecutorMock("workingDir\\ndepend-app.exe", "workingDir\\NDependResults /OutDir workingDir\\NDependResults", "workingDir", 600000);
            var fileSystem = mocks.StrictMock<IFileSystem>();
            Expect.Call(fileSystem.DirectoryExists(workingDir)).Return(true).Repeat.Times(2);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[0]);
            Expect.Call(fileSystem.GetFilesInDirectory(workingDir)).Return(new string[] {
                "workingDir\\file1.txt",
                "workingDir\\file2.xml"
            });
            Expect.Call(() => fileSystem.EnsureFolderExists("artefactDir\\1\\NDepend"));
            Expect.Call(() => fileSystem.Copy("workingDir\\file1.txt", "artefactDir\\1\\NDepend\\file1.txt"));
            Expect.Call(() => fileSystem.Copy("workingDir\\file2.xml", "artefactDir\\1\\NDepend\\file2.xml"));
            Expect.Call(fileSystem.GenerateTaskResultFromFile("workingDir\\file2.xml")).Return(mocks.DynamicMock<ITaskResult>());
            var logger = mocks.DynamicMock<ILogger>();
            var task = new NDependTask(executor, fileSystem, logger);
            task.Executable = "ndepend-app.exe";

            Expect.Call(result.Status).PropertyBehavior();
            mocks.ReplayAll();
            result.Status = IntegrationStatus.Unknown;
            task.Run(result);
            mocks.VerifyAll();
        }
Пример #8
0
 public void DefaultConstructorSetsFileSystemAndLogger()
 {
     var task = new NDependTask();
     Assert.IsInstanceOfType(typeof(SystemIoFileSystem), task.FileSystem);
     Assert.IsInstanceOfType(typeof(DefaultLogger), task.Logger);
 }