public void SimpleInjectorBootstrapper_ShouldCreateAContainer_WithILoggerRegistered() { // arrange _container.Verify(VerificationOption.VerifyOnly); string expectedLoggerObjectGraph = "SimpleLogger()"; // act InstanceProducer loggerInstanceProducer = _container.GetRegistration(typeof(ILogger)); string actualLoggerObjectGraph = loggerInstanceProducer.VisualizeObjectGraph(); // assert DiagnosticResult[] diagnosticResults = Analyzer.Analyze(_container); diagnosticResults.Length.Should().Be(0); expectedLoggerObjectGraph.Should().Be(actualLoggerObjectGraph); }
public void VisualizeObjectGraph_WhenCalledBeforeInstanceIsCreated_ThrowsAnInvalidOperationException() { // Arrange var container = new Container(); container.Register <RealTimeProvider>(); InstanceProducer producer = container.GetRegistration(typeof(RealTimeProvider)); // Act Action action = () => producer.VisualizeObjectGraph(); // Assert AssertThat.Throws <InvalidOperationException>(action, "When the instance hasn't been created or the Expression hasn't been built, there's not yet " + "enough information to visualize the object graph. Instead of returning an incorrect result " + "we expect the library to throw an exception here."); }