Exemplo n.º 1
0
        public void UseDiscoveredModules_ValidatesArguments()
        {
            // Arrange
            var builder = new TestWebHostBuilder();

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => ModuleWebHostBuilderExtensions.UseDiscoveredModules(null /* builder */));
        }
Exemplo n.º 2
0
        public void UseDiscoveredModules_AddsPartManager_ToServiceCollection()
        {
            // Arrange
            var builder = new TestWebHostBuilder();

            // Act
            ModuleWebHostBuilderExtensions.UseDiscoveredModules(builder);

            // Assert
            var descriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(IPartManager));

            Assert.NotNull(descriptor);
        }
Exemplo n.º 3
0
        public void UseDiscoveredModules_AddsPartManager_ToServiceCollection_WithDiscoveredModuleAssemblyParts()
        {
            // Arrange
            var builder = new TestWebHostBuilder();

            // Act
            ModuleWebHostBuilderExtensions.UseDiscoveredModules(builder);

            // Assert
            var descriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(IPartManager));

            Assert.NotNull(descriptor);

            var manager = (IPartManager)descriptor.ImplementationInstance;

            Assert.Contains(manager.Parts, p => p.Name == "Alium.Core");
        }
Exemplo n.º 4
0
        public void UseDiscoveredModules_AddsModuleProvider_ToServiceCollection_WithDiscoveredModules()
        {
            // Arrange
            var builder = new TestWebHostBuilder();

            // Act
            ModuleWebHostBuilderExtensions.UseDiscoveredModules(builder);

            // Assert
            var descriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(IModuleProvider));

            Assert.NotNull(descriptor);

            var provider = (IModuleProvider)descriptor.ImplementationInstance;

            Assert.Contains(provider.Modules, m => m is CoreModule);
        }