Ejemplo n.º 1
0
        public void CommandLine_OptionsAreParsedCorrectly()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] {
                "--no-restore",
                "--include", "include1", "include2",
                "--exclude", "exclude1", "exclude2",
                "--verify-no-changes",
                "--binarylog", "binary-log-path",
                "--report", "report",
                "--verbosity", "detailed",
                "--include-generated"
            });

            // Assert
            Assert.Equal(0, result.Errors.Count);
            Assert.Equal(0, result.UnmatchedTokens.Count);
            Assert.Equal(0, result.UnparsedTokens.Count);
            result.GetValueForOption <bool>("--no-restore");
            Assert.Collection(result.GetValueForOption <IEnumerable <string> >("--include"),
                              i0 => Assert.Equal("include1", i0),
                              i1 => Assert.Equal("include2", i1));
            Assert.Collection(result.GetValueForOption <IEnumerable <string> >("--exclude"),
                              i0 => Assert.Equal("exclude1", i0),
                              i1 => Assert.Equal("exclude2", i1));
            Assert.True(result.GetValueForOption <bool>("--verify-no-changes"));
            Assert.Equal("binary-log-path", result.GetValueForOption <string>("--binarylog"));
            Assert.Equal("report", result.GetValueForOption <string>("--report"));
            Assert.Equal("detailed", result.GetValueForOption <string>("--verbosity"));
            Assert.True(result.GetValueForOption <bool>("--include-generated"));
        }
Ejemplo n.º 2
0
        public void CommandLine_Diagnostics_DoesNotFailIfMultipleDiagnosticAreSpecified()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "--diagnostics", "RS0016", "RS0017", "RS0018" });

            // Assert
            Assert.Equal(0, result.Errors.Count);
        }
Ejemplo n.º 3
0
        public void CommandLine_BinaryLog_FailsIfFolderIsSpecified()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "whitespace", "--folder", "--binarylog" });

            // Assert
            Assert.Equal(1, result.Errors.Count);
        }
Ejemplo n.º 4
0
        public void CommandLine_Diagnostics_FailsIfDiagnosticNoSpecified()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "--diagnostics" });

            // Assert
            Assert.Equal(1, result.Errors.Count);
        }
Ejemplo n.º 5
0
        public void CommandLine_FolderValidation_FailsIfNoRestoreSpecified()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "whitespace", "--folder", "--no-restore" });

            // Assert
            Assert.Equal(1, result.Errors.Count);
        }
Ejemplo n.º 6
0
        public void CommandLine_FolderValidation_FailsIfFixStyleSpecified()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "--folder", "--fix-style" });

            // Assert
            Assert.Equal(1, result.Errors.Count);
        }
Ejemplo n.º 7
0
        public void CommandLine_ProjectArgument_FailsIfSpecifiedTwice()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "workspaceValue1", "workspaceValue2" });

            // Assert
            Assert.Equal(1, result.Errors.Count);
        }
Ejemplo n.º 8
0
        public void CommandLine_ProjectArgument_Simple()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "workspaceValue" });

            // Assert
            Assert.Equal(0, result.Errors.Count);
            Assert.Equal("workspaceValue", result.GetValueForArgument <string>(FormatCommandCommon.SlnOrProjectArgument));
        }
Ejemplo n.º 9
0
        public void CommandLine_BinaryLog_DoesNotFailIfPathIsSpecified()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "--binarylog", "log" });

            // Assert
            Assert.Equal(0, result.Errors.Count);
            Assert.True(result.WasOptionUsed("--binarylog"));
        }
Ejemplo n.º 10
0
        public void CommandLine_ProjectArgument_WithOption_AfterArgument()
        {
            // Arrange
            var sut = RootFormatCommand.GetCommand();

            // Act
            var result = sut.Parse(new[] { "workspaceValue", "--verbosity", "detailed" });

            // Assert
            Assert.Equal(0, result.Errors.Count);
            Assert.Equal("workspaceValue", result.GetValueForArgument <string>(FormatCommandCommon.SlnOrProjectArgument));
            Assert.Equal("detailed", result.GetValueForOption <string>("--verbosity"));
        }
Ejemplo n.º 11
0
        private static async Task <int> Main(string[] args)
        {
            var rootCommand = RootFormatCommand.GetCommand();

            return(await rootCommand.InvokeAsync(args));
        }