Ejemplo n.º 1
0
        GivenCompositionModuleRegistersDependencyAsSingleton_WhenCompositionModulesRegistrationIsInvoked_ThenDependencyIsRegistered
            ()
        {
            var container = new FakeIocContainer();

            container.RegisterContainerAdapterCompositionModules(new ICompositionModule[]
            {
                new TransientIocCompositionModule()
            });

            var registrations          = container.Registrations;
            var dependencyRegistration = registrations.First();

            dependencyRegistration.ImplementationType.Should().Be(typeof(TransientDependency));
            dependencyRegistration.InterfaceType.Should().Be(typeof(IDependency));
            dependencyRegistration.IsSingleton.Should().Be(false);
        }
Ejemplo n.º 2
0
        GivenThereAreTwoServicesThatImplementTheContract_WhenRegisterCollectionMiddlewareIsApplied_ThenBothServicesAreRegistered
            ()
        {
            var containerAdapter = new FakeIocContainer();
            var bootstrapper     = new FakeBootstrapper
            {
                Registrator = containerAdapter,
                Assemblies  = new[] { typeof(FakeIocContainer).GetTypeInfo().Assembly }
            };

            var middleware = new RegisterCollectionMiddleware <FakeBootstrapper>(typeof(IServiceContract));

            middleware.Apply(bootstrapper);

            var registrations          = containerAdapter.Registrations;
            var dependencyRegistration = registrations.First();

            (dependencyRegistration.InterfaceType == typeof(IEnumerable <IServiceContract>)).Should().BeTrue();
        }
Ejemplo n.º 3
0
        GivenCompositionModuleRegistersDependencyAsSingleton_WhenRegisterContainerAdapterCompositionModulesMiddlewareIsApplied_ThenDependencyIsRegistered
            ()
        {
            var container    = new FakeIocContainer();
            var bootstrapper = new FakeBootstrapper
            {
                Registrator = container,
                Modules     = new ICompositionModule[]
                {
                    new TransientIocCompositionModule()
                }
            };

            var middleware = new RegisterCompositionModulesMiddleware <FakeBootstrapper>();

            middleware.Apply(bootstrapper);

            var registrations          = container.Registrations;
            var dependencyRegistration = registrations.First();

            dependencyRegistration.ImplementationType.Should().Be(typeof(TransientDependency));
            dependencyRegistration.InterfaceType.Should().Be(typeof(IDependency));
            dependencyRegistration.IsSingleton.Should().Be(false);
        }