示例#1
0
            public void Should_Add_Additional_Arguments()
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Settings.Diagnostics.Add("CS123");
                fixture.Settings.Diagnostics.Add("CA555");
                fixture.Settings.Severity        = DotNetFormatSeverity.Warning;
                fixture.Settings.NoRestore       = true;
                fixture.Settings.VerifyNoChanges = true;
                fixture.Settings.Include.Add("./src/");
                fixture.Settings.Include.Add("./tests/");
                fixture.Settings.Exclude.Add("./src/submodule-a/");
                fixture.Settings.IncludeGenerated = true;
                fixture.Settings.Verbosity        = Common.Tools.DotNet.DotNetVerbosity.Diagnostic;
                fixture.Settings.BinaryLog        = "./temp/b.log";
                fixture.Settings.Report           = "./temp/report.json";
                fixture.Root = "./src/project";

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

                // Then
                var expected = "format \"./src/project\" --diagnostics CS123 CA555 --severity warn --no-restore --verify-no-changes --include ./src/ ./tests/ --exclude ./src/submodule-a/ --include-generated";

                expected += " --binarylog \"/Working/temp/b.log\" --report \"/Working/temp/report.json\" --verbosity diagnostic";
                Assert.Equal(expected, result.Args);
            }
示例#2
0
            public void Should_Quote_Root_Path(string text, string expected)
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Root = text;

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

                // Then
                Assert.Equal(expected, result.Args);
            }
示例#3
0
            public void Should_Add_Mandatory_Arguments()
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Root = "./src/project";

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

                // Then
                Assert.Equal("format \"./src/project\"", result.Args);
            }
示例#4
0
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Root = "./src/project";
                fixture.GivenProcessExitsWithCode(1);

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

                // Then
                AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1).");
            }
示例#5
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Root = "./src/project";
                fixture.GivenProcessCannotStart();

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

                // Then
                AssertEx.IsCakeException(result, ".NET CLI: Process was not started.");
            }
示例#6
0
            public void Should_Throw_If_Root_Is_Null()
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Settings = new DotNetFormatSettings();
                fixture.GivenDefaultToolDoNotExist();

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

                // Then
                AssertEx.IsArgumentNullException(result, "root");
            }
示例#7
0
            public void Should_Add_Subcommand()
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Root       = "./src/project";
                fixture.Subcommand = "style";

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

                // Then
                Assert.Equal("format style \"./src/project\"", result.Args);
            }
示例#8
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new DotNetFormatterFixture();

                fixture.Root     = "./src/project";
                fixture.Settings = null;
                fixture.GivenDefaultToolDoNotExist();

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

                // Then
                AssertEx.IsArgumentNullException(result, "settings");
            }