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); }
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); }
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); }
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); }
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); }
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); }
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); }