public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException() { var mockHttpApplication = new MockHttpApplication(null, false); mockHttpApplication.BeginRequest(); var exception = Assert.Throws<InvalidOperationException>(() => serviceContainer.GetInstance<IFoo>()); Assert.Contains("Unable to locate a scope manager for the current HttpRequest.", exception.Message); }
public void ShouldHandleNullApplication() { var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), true); mockHttpApplication.BeginRequest(); mockHttpApplication.EndRequest(); }
public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException() { var mockHttpApplication = new MockHttpApplication(null); mockHttpApplication.BeginRequest(); ExceptionAssert.Throws<InvalidOperationException>( () => serviceContainer.GetInstance<IFoo>(), e => e.ToString().Contains("Unable to locate a scope manager for the current HttpRequest.")); }
public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException() { var mockHttpApplication = new MockHttpApplication(null, false); mockHttpApplication.BeginRequest(); var exception = Assert.Throws <InvalidOperationException>(() => serviceContainer.GetInstance <IFoo>()); Assert.Contains("Unable to locate a scope manager for the current HttpRequest.", exception.Message); }
private static IFoo GetInstanceWithinWebRequest() { var mockHttpApplication = new MockHttpApplication(); mockHttpApplication.BeginRequest(); IFoo firstInstance = serviceContainer.GetInstance<IFoo>(); mockHttpApplication.EndRequest(); mockHttpApplication.Dispose(); return firstInstance; }
public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException() { var mockHttpApplication = new MockHttpApplication(null); mockHttpApplication.BeginRequest(); ExceptionAssert.Throws <InvalidOperationException>( () => serviceContainer.GetInstance <IFoo>(), e => e.ToString().Contains("Unable to locate a scope manager for the current HttpRequest.")); }
private static IFoo GetInstanceWithinWebRequest() { serviceContainer.EnablePerWebRequestScope(); var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), false); mockHttpApplication.BeginRequest(); IFoo firstInstance = serviceContainer.GetInstance<IFoo>(); mockHttpApplication.EndRequest(); mockHttpApplication.Dispose(); return firstInstance; }
private static IFoo GetInstanceWithinWebRequest() { var mockHttpApplication = new MockHttpApplication(); mockHttpApplication.BeginRequest(); IFoo firstInstance = serviceContainer.GetInstance <IFoo>(); mockHttpApplication.EndRequest(); mockHttpApplication.Dispose(); return(firstInstance); }
private static IFoo GetInstanceWithinWebRequest() { serviceContainer.EnablePerWebRequestScope(); var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), false); mockHttpApplication.BeginRequest(); IFoo firstInstance = serviceContainer.GetInstance <IFoo>(); mockHttpApplication.EndRequest(); mockHttpApplication.Dispose(); return(firstInstance); }
public void GetInstance_InsideWebRequest_ReturnsSameInstance() { var mockHttpApplication = new MockHttpApplication(); mockHttpApplication.BeginRequest(); var firstInstance = serviceContainer.GetInstance<IFoo>(); var secondInstance = serviceContainer.GetInstance<IFoo>(); Assert.AreEqual(firstInstance, secondInstance); mockHttpApplication.EndRequest(); }
public void GetInstance_InsideWebRequest_ReturnsSameInstance() { var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), false); mockHttpApplication.BeginRequest(); var firstInstance = serviceContainer.GetInstance <IFoo>(); var secondInstance = serviceContainer.GetInstance <IFoo>(); Assert.Equal(firstInstance, secondInstance); mockHttpApplication.EndRequest(); }