public void When_nonframework_dependency_constructor_throws_then_exception_is_thrown() { var container = new PocketContainer(); container.Register <IMyDependency>(c => new DependencyThatThrowOnConstruction()); var sut = new PocketContainerDependencyResolver(container); Action resolveFrameworkDependency = () => sut.GetService(typeof(IMyDependency)); resolveFrameworkDependency.ShouldThrow <HttpParseException>("because GetService is resolving our own interface"); }
public void When_framework_dependency_constructor_throws_then_exception_is_thrown() { var container = new PocketContainer(); container.Register <IContentNegotiator>(c => new DependencyThatThrowOnConstruction()); var sut = new PocketContainerDependencyResolver(container); Action resolveFrameworkDependency = () => sut.GetService(typeof(IContentNegotiator)); resolveFrameworkDependency.ShouldThrow <HttpParseException>( "because framework service implementation constructor threw an exception"); }
public void When_framework_dependency_constructor_cannot_be_satisfied_then_exception_is_swallowed() { var container = new PocketContainer(); container.Register <IContentNegotiator>(c => c.Resolve <UnsastisfiableDependency>()); var sut = new PocketContainerDependencyResolver(container); Action resolveFrameworkDependency = () => sut.GetService(typeof(IContentNegotiator)); Action resolveFrameworkDependencies = () => sut.GetServices(typeof(IContentNegotiator)).ToArray(); resolveFrameworkDependency.ShouldNotThrow("because we're resolving a framework service"); resolveFrameworkDependencies.ShouldNotThrow("because we're resolving a framework service"); }
public void When_nonframework_dependency_constructor_cannot_be_satisfied_then_exception_is_thrown() { var container = new PocketContainer(); container.Register <IMyDependency>(c => c.Resolve <UnsastisfiableDependency>()); var sut = new PocketContainerDependencyResolver(container); Action resolveFrameworkDependency = () => sut.GetService(typeof(IMyDependency)); resolveFrameworkDependency.ShouldThrow <ArgumentException>("because GetService is resolving our own interface") .And .Message .Should() .Contain("+IAmUnregistered"); }