Beispiel #1
0
            public void Should_Set_Caches_Home()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.CachesHome = "caches/";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("\"/caches-home=/Working/caches\" " +
                             "\"/Working/Test.sln\"", result.Args);
            }
Beispiel #2
0
            public void Should_Set_Resharper_Plugins()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.Extensions = new[] { "ReSharper.AgentSmith", "X.Y" };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("\"/extensions=ReSharper.AgentSmith;X.Y\" " +
                             "\"/Working/Test.sln\"", result.Args);
            }
Beispiel #3
0
            public void Should_Throw_If_OutputFile_Contains_Violations_And_Set_To_Throw()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.OutputFile = new FilePath("build/violations.xml");
                fixture.Settings.ThrowExceptionOnFindingViolations = true;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsCakeException(result, "Code Inspection Violations found in code base.");
            }
Beispiel #4
0
            public void Should_Set_Output()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.OutputFile = "build/inspect_code.xml";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("\"/output:/Working/build/inspect_code.xml\" " +
                             "\"/Working/Test.sln\"", result.Args);
            }
Beispiel #5
0
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.GivenProcessExitsWithCode(1);

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("InspectCode: Process returned an error (exit code 1).", result.Message);
            }
Beispiel #6
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.GivenProcessCannotStart();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("InspectCode: Process was not started.", result.Message);
            }
Beispiel #7
0
            public void Should_Set_Profile()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.Profile = "profile.DotSettings";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("\"/profile=/Working/profile.DotSettings\" " +
                             "\"/Working/Test.sln\"", result.Args);
            }
            public void Should_Throw_If_Solution_Wide_Analysis_Is_Both_Disabled_And_Enabled()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.SolutionWideAnalysis   = true;
                fixture.Settings.NoSolutionWideAnalysis = true;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <ArgumentException>(result);
                Assert.Equal("InspectCode: You can't set both SolutionWideAnalysis and NoSolutionWideAnalysis to true", result?.Message);
            }
            public void Should_Set_MsBuild_Properties()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.MsBuildProperties = new Dictionary <string, string>();
                fixture.Settings.MsBuildProperties.Add("TreatWarningsAsErrors", "true");
                fixture.Settings.MsBuildProperties.Add("Optimize", "false");

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("\"/properties:TreatWarningsAsErrors=true\" " +
                             "\"/properties:Optimize=false\" " +
                             "\"/Working/Test.sln\"", result.Args);
            }
Beispiel #10
0
            public void Should_Analyze_Output()
            {
                var log = new FakeLog();

                // Given
                var fixture = new InspectCodeRunFixture
                {
                    Log = log
                };

                fixture.Settings.OutputFile = new FilePath("build/violations.xml");

                // When
                fixture.Run();

                // Then
                var logContainsInspectionResults =
                    log.Entries.Any(p => p.Message.StartsWith("Code Inspection Error(s) Located."));

                Assert.True(logContainsInspectionResults);
            }
            public void Should_Set_Disabled_Settings_Layers()
            {
                // Given
                var fixture = new InspectCodeRunFixture();

                fixture.Settings.DisabledSettingsLayers = new[]
                {
                    SettingsLayer.GlobalAll,
                    SettingsLayer.GlobalPerProduct,
                    SettingsLayer.SolutionShared,
                    SettingsLayer.SolutionPersonal,
                    SettingsLayer.ProjectShared,
                    SettingsLayer.ProjectPersonal,
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("\"/dsl=GlobalAll;GlobalPerProduct;" +
                             "SolutionShared;SolutionPersonal;" +
                             "ProjectShared;ProjectPersonal\" " +
                             "\"/Working/Test.sln\"", result.Args);
            }