public void AddModuleServices_ValidatesArguments() { // Arrange var services = new ServiceCollection(); // Act // Assert Assert.Throws <ArgumentNullException>(() => ServiceCollectionExtensions.AddModuleServices(null /* services */, null /* moduleProvider */)); Assert.Throws <ArgumentNullException>(() => ServiceCollectionExtensions.AddModuleServices(services, null /* moduleProvider */)); }
public void AddModuleServices_AddsServicesFromModule() { // Arrange var module = new TestModule(); var moduleProvider = new ModuleProvider(new[] { module }); var services = new ServiceCollection(); // Act ServiceCollectionExtensions.AddModuleServices(services, moduleProvider); // Assert var descriptor = services.FirstOrDefault(sd => sd.ServiceType == typeof(IServiceOne)); Assert.NotNull(descriptor); }
public void AddModuleServices_AddsModuleProvider() { // Arrange var module = new TestModule(); var moduleProvider = new ModuleProvider(new[] { module }); var services = new ServiceCollection(); // Act ServiceCollectionExtensions.AddModuleServices(services, moduleProvider); // Assert var descriptor = services.FirstOrDefault(sd => sd.ServiceType == typeof(IModuleProvider)); Assert.NotNull(descriptor); Assert.Equal(ServiceLifetime.Singleton, descriptor.Lifetime); }