コード例 #1
0
        public void RepositoryPath_must_exists()
        {
            // ARRANGE
            using var temporaryDirectory = new TemporaryDirectory();
            var nonExistingDirectory = Path.Combine(temporaryDirectory, "someDir");

            var parameters = new CommandLineParameters()
            {
                RepositoryPath = nonExistingDirectory
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.False(result.IsValid);
            var error = Assert.Single(result.Errors);

            Assert.Equal(nameof(CommandLineParameters.RepositoryPath), error.PropertyName);

            // error message should contain commandline parameter name (specified using the Option attribute) instead of the property name
            Assert.Contains("'repository'", error.ErrorMessage);
        }
コード例 #2
0
        public void ConfigurationFilePath_must_exists_if_parameter_is_set()
        {
            // ARRANGE
            using var repositoryDirectory = new TemporaryDirectory();
            var configurationFilePath = Path.Combine(repositoryDirectory, "config.json");

            var parameters = new CommandLineParameters()
            {
                RepositoryPath        = repositoryDirectory,
                ConfigurationFilePath = configurationFilePath
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.False(result.IsValid);
            var error = Assert.Single(result.Errors);

            Assert.Equal(nameof(CommandLineParameters.ConfigurationFilePath), error.PropertyName);

            // error message should contain commandline parameter name (specified using the Option attribute) instead of the property name
            Assert.Contains("'configurationFilePath'", error.ErrorMessage);
        }
コード例 #3
0
        public void VersionRange_must_be_a_valid_version_range_if_parameter_is_set(string version)
        {
            // ARRANGE
            using var repositoryDirectory = new TemporaryDirectory();

            var parameters = new CommandLineParameters()
            {
                RepositoryPath = repositoryDirectory,
                VersionRange   = version
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.False(result.IsValid);
            var error = Assert.Single(result.Errors);

            Assert.Equal(nameof(CommandLineParameters.VersionRange), error.PropertyName);

            // error message should contain commandline parameter name (specified using the Option attribute) instead of the property name
            Assert.Contains("'versionRange'", error.ErrorMessage);
        }
コード例 #4
0
        public void RepositoryPath_may_be_empty(string repositoryPath)
        {
            // ARRANGE
            var parameters = new CommandLineParameters()
            {
                RepositoryPath = repositoryPath
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.True(result.IsValid);
            Assert.Empty(result.Errors);
        }
コード例 #5
0
        public void CurrentVersion_may_be_empty(string value)
        {
            // ARRANGE
            using var repositoryDirectory = new TemporaryDirectory();
            var parameters = new CommandLineParameters()
            {
                RepositoryPath = repositoryDirectory,
                CurrentVersion = value
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.True(result.IsValid);
            Assert.Empty(result.Errors);
        }
コード例 #6
0
        public void ConfigurationFilePath_may_be_empty(string path)
        {
            // ARRANGE
            using var repositoryDirectory = new TemporaryDirectory();
            var parameters = new CommandLineParameters()
            {
                RepositoryPath        = repositoryDirectory,
                ConfigurationFilePath = path
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.True(result.IsValid);
            Assert.Empty(result.Errors);
        }
コード例 #7
0
        public void RepositoryPath_must__not_be_whitespace(string repositoryPath)
        {
            // ARRANGE
            var parameters = new CommandLineParameters()
            {
                RepositoryPath = repositoryPath
            };

            var validator = new CommandLineParametersValidator();

            // ACT
            var result = validator.Validate(parameters);

            // ASSERT
            Assert.False(result.IsValid);
            var error = Assert.Single(result.Errors);

            Assert.Equal(nameof(CommandLineParameters.RepositoryPath), error.PropertyName);

            // error message should contain commandline parameter name (specified using the Option attribute) instead of the property name
            Assert.Contains("'repository'", error.ErrorMessage);
        }