コード例 #1
0
        public void Verify_MissingDependencyRegistration_InvalidOperationException()
        {
            // Assign
            _provider.Register <Foo>();

            // Act && Assert

            var ex = Assert.Throws <DependencyResolutionException>(() => _provider.Verify());

            Assert.That(ex !.Message, Does.StartWith("An exception was thrown while activating Simplify.DI.TestsTypes.Foo"));
        }
コード例 #2
0
        public void Verify_MissingDependencyRegistration_ContainerException()
        {
            // Assign
            _provider.Register <Foo>();

            // Act && Assert

            var ex = Assert.Throws <ContainerException>(() => _provider.Verify());

            Assert.That(ex.Message, Does.StartWith("Unable to resolve"));
            Assert.That(ex.Message, Does.Contain("IBar as parameter \"bar\""));
        }
コード例 #3
0
        public void Verify_MissingDependencyRegistration_MisconfiguredComponentException()
        {
            // Assign
            _provider.Register <Foo>();

            // Act && Assert

            var ex = Assert.Throws <MisconfiguredComponentException>(() => _provider.Verify());

            Assert.That(ex.Message, Does.Contain("'Simplify.DI.TestsTypes.Foo' is waiting for the following dependencies:"));
            Assert.That(ex.Message, Does.Contain("Service 'Simplify.DI.TestsTypes.IBar' which was not registered."));
        }
        public void Verify_MissingDependencyRegistration_InvalidOperationException()
        {
            // Assign
            _provider.Register <Foo>();

            // Act && Assert

            var ex = Assert.Throws <InvalidOperationException>(() => _provider.Verify());

            Assert.That(ex.Message,
                        Does.StartWith("Unable to resolve service for type 'Simplify.DI.TestsTypes.IBar' while attempting to activate 'Simplify.DI.TestsTypes.Foo'."));
        }
コード例 #5
0
        /// <summary>
        /// Integrates Simplify.DI with Microsoft Dependency Injection system and verifies Simplify.DI provider.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="services">The services.</param>
        /// <returns></returns>
        public static IServiceProvider IntegrateWithMicrosoftDependencyInjectionAndVerify(this IDIContainerProvider provider, IServiceCollection services)
        {
            var serviceProvider = provider.IntegrateWithMicrosoftDependencyInjection(services);

            provider.Verify();

            return(serviceProvider);
        }
コード例 #6
0
        public void Verify_MissingDependencyRegistration_InvalidOperationException()
        {
            // Assign
            _provider.Register <Foo>();

            // Act && Assert

            var ex = Assert.Throws <InvalidOperationException>(() => _provider.Verify());

            Assert.That(ex.Message,
                        Does.StartWith("The configuration is invalid. Creating the instance for type Foo failed. The constructor of type Foo contains the parameter with name 'bar' and type IBar that is not registered."));
        }