Exemplo n.º 1
0
        public void ItShouldFindTestModule()
        {
            ImmutableArray <OrderedModuleRegistration> registrations = ModuleExtensions.GetModules(
                new[] { GetType().Assembly },
                Array.Empty <Type>(),
                new NoConfiguration());

            Assert.NotEmpty(registrations);
            Assert.Contains(
                registrations,
                orderedModuleRegistration =>
                orderedModuleRegistration.ModuleRegistration.ModuleType == typeof(TestModule));
        }
Exemplo n.º 2
0
        public void ShouldBeFound()
        {
            ImmutableArray <OrderedModuleRegistration> registrations = ModuleExtensions.GetModules(
                new[] { GetType().Assembly },
                Array.Empty <Type>(),
                new NoConfiguration());

            OrderedModuleRegistration orderedModuleRegistration =
                registrations.SingleOrDefault(moduleRegistration =>
                                              moduleRegistration.ModuleRegistration.ModuleType == typeof(SimpleNoOpTestModule));

            Assert.NotNull(orderedModuleRegistration);
        }
Exemplo n.º 3
0
        public void ShouldRegisterInRootScopeFalse()
        {
            ImmutableArray <OrderedModuleRegistration> registrations = ModuleExtensions.GetModules(
                new[] { GetType().Assembly },
                Array.Empty <Type>(),
                new NoConfiguration());

            OrderedModuleRegistration orderedModuleRegistration =
                registrations.SingleOrDefault(moduleRegistration =>
                                              moduleRegistration.ModuleRegistration.ModuleType == typeof(SimpleNoOpTestModule));

            Assert.False(orderedModuleRegistration?.ModuleRegistration?.RegisterInRootScope);
        }
Exemplo n.º 4
0
        public void ShouldBeFound()
        {
            ImmutableArray <OrderedModuleRegistration> registrations = ModuleExtensions.GetModules(
                new[] { GetType().Assembly },
                Array.Empty <Type>(),
                new NoConfiguration());

            OrderedModuleRegistration orderedModuleRegistration =
                registrations.SingleOrDefault(moduleRegistration =>
                                              moduleRegistration.ModuleRegistration.ModuleType == typeof(NoOpTestModule));

            Assert.Equal(37, orderedModuleRegistration?.ModuleRegistration?.Order);
            Assert.Equal(Scope.AspNetCoreScope, orderedModuleRegistration?.ModuleRegistration?.Tag);
            Assert.True(orderedModuleRegistration?.ModuleRegistration?.RegisterInRootScope);
        }
Exemplo n.º 5
0
        public void ItShouldInstantiateModule()
        {
            var nameValueCollection = new NameValueCollection
            {
                { nameof(NoOpTestModule.MeaningOfLife), "42" }
            };

            ImmutableArray <OrderedModuleRegistration> registrations = ModuleExtensions.GetModules(
                new[] { GetType().Assembly },
                Array.Empty <Type>(),
                new InMemoryKeyValueConfiguration(nameValueCollection));

            OrderedModuleRegistration orderedModuleRegistration =
                registrations.SingleOrDefault(moduleRegistration =>
                                              moduleRegistration.ModuleRegistration.ModuleType == typeof(NoOpTestModule));

            Assert.NotNull(orderedModuleRegistration);

            var module = orderedModuleRegistration.Module as NoOpTestModule;

            Assert.NotNull(module);

            Assert.Equal("42", module.MeaningOfLife);
        }