public static IServiceCollection AddTicketingConnector( this IServiceCollection services, IHostingEnvironment env, IConfigurationRoot config, TicketingConnectorConfig connectorConfig) { if (connectorConfig == null) { return(services.AddNoTicketingSystem()); } if (!String.IsNullOrWhiteSpace(connectorConfig.Path)) { return(services .LoadConnectorFromAssembly( env, config, connectorConfig.Path )); } if (connectorConfig.Proxy != null) { return(services.AddProxyConnector(connectorConfig.Proxy)); } return(services.AddNoTicketingSystem()); }
public void AddTicketingConnector_Returns_Service_WithNo_TicketingSystem_When_ConnectorConfigPathIsWhiteSpace() { var mockServices = new SpyServiceCollection(); var mockEnv = new Mock <IHostingEnvironment>(); var mockConfig = new Mock <IConfigurationRoot>(); var mockConnectorConfig = new TicketingConnectorConfig(); mockConnectorConfig.Path = ""; var result = mockServices.AddTicketingConnector(mockEnv.Object, mockConfig.Object, mockConnectorConfig); var finalResult = result.ToArray(); Assert.AreEqual(finalResult[0].ImplementationType.Name, "NoClient"); Assert.AreEqual(finalResult[1].ImplementationType.Name, "NoConnector"); }