コード例 #1
0
        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 */));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }