public void Service_Does_Not_Exist_Returns_Default_Instance() { // Arrange var config = new ServicesConfig(); var name = Rnd.Str; var defaultConfig = new ConsoleConfig(); // Act var result = config.GetServiceConfig(x => x.Console, name); // Assert Assert.Equal(defaultConfig.AddPrefix, result.AddPrefix); Assert.Equal(defaultConfig.Template, result.Template); }
public void Splits_Definition_Unknown_Service_Type_Throws_UnsupportedServiceException() { // Arrange var config = new ServicesConfig(); var type = Rnd.Str; // Act var action = void() => config.GetServiceConfig($"{type}.{Rnd.Str}"); // Assert var ex = Assert.Throws <UnsupportedServiceException>(action); Assert.Equal(string.Format(UnsupportedServiceException.Format, type), ex.Message); }
public void Invalid_Config_Throws_InvalidServiceConfigurationException() { // Arrange var config = new ServicesConfig(); var name = Rnd.Str; config.Seq.Add(name, new SeqConfig()); // Act var action = void() => config.GetServiceConfig(x => x.Seq, name); // Assert var ex = Assert.Throws <InvalidServiceConfigurationException>(action); Assert.Equal(string.Format(InvalidServiceConfigurationException.Format, name, typeof(SeqConfig)), ex.Message); }
public void Returns_ServiceConfig() { // Arrange var config = new ServicesConfig(); var name = Rnd.Str; var service = new SeqConfig { Server = "https://www.contoso.com", ApiKey = Rnd.Str }; config.Seq.Add(name, service); // Act var result = config.GetServiceConfig(x => x.Seq, name); // Assert Assert.Equal(service, result); }
public void Splits_Definition_And_Returns_ServiceConfig() { // Arrange var config = new ServicesConfig(); var name = Rnd.Str; var service = new SeqConfig { Server = "https://www.contoso.com", ApiKey = Rnd.Str }; config.Seq.Add(name, service); // Act var result = config.GetServiceConfig($"seq.{name}"); // Assert Assert.Equal(service, result); }