示例#1
0
            public void Should_Throw_If_Config_File_Is_Null()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.RunFromConfig(null));

                // Then
                Assert.IsArgumentNullException(result, "configFile");
            }
示例#2
0
            public void Should_Throw_If_Projects_Are_Null()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run(null, new DupFinderSettings()));

                // Then
                Assert.IsArgumentNullException(result, "files");
            }
示例#3
0
            public void Should_Find_Inspect_Code_Runner()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings());

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Is <FilePath>(p => p.FullPath == "/Working/tools/dupfinder.exe"),
                    Arg.Any <ProcessSettings>());
            }
示例#4
0
            public void Should_Use_Provided_Files_In_Process_Arguments()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run(new[] { FilePath.FromString("./Test.sln"), FilePath.FromString("./Test.csproj") }, new DupFinderSettings());

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/Working/Test.sln\" \"/Working/Test.csproj\"", fixture.ProcessArguments);
            }
示例#5
0
            public void Should_Use_Provided_Config_File()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.RunFromConfig(FilePath.FromString("config.xml"));

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/config=/Working/config.xml\"", fixture.ProcessArguments);
            }
示例#6
0
            public void Should_Throw_If_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();

                fixture.Process.GetExitCode().Returns(1);
                var runner = fixture.CreateRunner();

                // When
                var result =
                    Record.Exception(
                        () => runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings()));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("DupFinder: Process returned an error.", result.Message);
            }
示例#7
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();

                fixture.ProcessRunner.Start(Arg.Any <FilePath>(), Arg.Any <ProcessSettings>()).Returns((IProcess)null);
                var runner = fixture.CreateRunner();

                // When
                var result =
                    Record.Exception(
                        () => runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings()));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("DupFinder: Process was not started.", result.Message);
            }
示例#8
0
            public void Should_Set_Show_Text_Switch()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    ShowText = true
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("/show-text \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#9
0
            public void Should_Set_Caches_Home()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    CachesHome = DirectoryPath.FromString("caches/")
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/caches-home=/Working/caches\" \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#10
0
            public void Should_Set_Exclude_Pattern()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    ExcludePattern = new[] { "*Tests.cs", "*Test.cs" }
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/exclude=*Tests.cs;*Test.cs\" \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#11
0
            public void Should_Set_Exclude_Code_Regions()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    ExcludeCodeRegionsByNameSubstring = new[] { "generated code", "test" }
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/exclude-code-regions=generated code;test\" \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#12
0
            public void Should_Set_Exclude_By_Comment()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    ExcludeFilesByStartingCommentSubstring = new[] { "test", "asdf" }
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/exclude-by-comment=test;asdf\" \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#13
0
            public void Should_Set_Discard_Local_Vars_Switch()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    DiscardLocalVariablesName = true
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("/discard-local-vars \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#14
0
            public void Should_Set_Discard_Cost()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    DiscardCost = 50,
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("/discard-cost=50 \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#15
0
            public void Should_Set_Output_File()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    OutputFile = FilePath.FromString("build/dupfinder.xml")
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/output=/Working/build/dupfinder.xml\" \"/Working/Test.sln\"", fixture.ProcessArguments);
            }
示例#16
0
            public void Should_Set_MSBuild_Properties()
            {
                // Given
                var fixture = new DupFinderRunnerFixture();
                var runner  = fixture.CreateRunner();

                // Then
                runner.Run(new[] { FilePath.FromString("./Test.sln") }, new DupFinderSettings
                {
                    MsBuildProperties = new Dictionary <string, string>
                    {
                        { "TreatWarningsAsErrors", "true" },
                        { "Optimize", "false" }
                    }
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Any <ProcessSettings>());
                Assert.Equal("\"/properties:TreatWarningsAsErrors=true\" \"/properties:Optimize=false\" \"/Working/Test.sln\"", fixture.ProcessArguments);
            }