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")); }
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\"")); }
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'.")); }
/// <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); }
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.")); }