public void Returns_Success_ForValid_Configuration() { var validator = new GlobalSettingsValidator(); var options = new GlobalSettings(); ValidateOptionsResult result = validator.Validate("settings", options); Assert.True(result.Succeeded); }
public void Returns_Fail_For_Configuration_With_Invalid_SmtpFrom_Field() { var validator = new GlobalSettingsValidator(); GlobalSettings options = BuildGlobalSettings(smtpEmail: "invalid"); ValidateOptionsResult result = validator.Validate("settings", options); Assert.False(result.Succeeded); }
public GlobalSettingsTests() { var fixture = new Fixture(); _settings = fixture.Create <GlobalSettings>(); _validator = new GlobalSettingsValidator(); }
public static IServiceCollection RegisterSettings(this IServiceCollection services, IConfiguration configuration) { var settings = configuration.GetSection("GlobalSettings").Get <GlobalSettings>(); var validator = new GlobalSettingsValidator(); validator.ValidateAndThrow(settings); return(services.AddSingleton <GlobalSettings>(settings)); }
public void Returns_Success_For_Configuration_With_Valid_SqlWriteLockTimeOut() { var validator = new GlobalSettingsValidator(); var options = new GlobalSettings { DistributedLockingWriteLockDefaultTimeout = TimeSpan.Parse("00:00:20") }; var result = validator.Validate("settings", options); Assert.True(result.Succeeded); }
public void Returns_Fail_For_Configuration_With_Excessive_SqlWriteLockTimeOut() { var validator = new GlobalSettingsValidator(); var options = new GlobalSettings { SqlWriteLockTimeOut = TimeSpan.Parse("00:00:21") }; ValidateOptionsResult result = validator.Validate("settings", options); Assert.False(result.Succeeded); }
public void Returns_Fail_For_Configuration_With_Insufficient_SqlWriteLockTimeOut() { var validator = new GlobalSettingsValidator(); var options = new GlobalSettings { DistributedLockingWriteLockDefaultTimeout = TimeSpan.Parse("00:00:00.099") }; ValidateOptionsResult result = validator.Validate("settings", options); Assert.False(result.Succeeded); }
public void Returns_Fail_For_Configuration_With_Invalid_SmtpFrom_Field() { var validator = new GlobalSettingsValidator(); var options = new GlobalSettings { Smtp = new SmtpSettings { From = "invalid" } }; var result = validator.Validate("settings", options); Assert.False(result.Succeeded); }