public void RegisterForDisposal_WithValidArgumentsInHttpContext_Succeeds() { // Arrange ScopedLifestyle lifestyle = new WebRequestLifestyle(); var validContainer = new Container(); IDisposable validInstance = new DisposableCommand(); using (new HttpContextScope()) { // Act lifestyle.RegisterForDisposal(validContainer, validInstance); } }
public void RegisterForDisposal_OutsideTheContextOfAHttpRequest_ThrowsExpectedException() { // Arrange ScopedLifestyle lifestyle = new WebRequestLifestyle(); var validContainer = new Container(); var validInstance = new DisposableCommand(); // Act Action action = () => lifestyle.RegisterForDisposal(validContainer, validInstance); // Assert AssertThat.ThrowsWithExceptionMessageContains <InvalidOperationException>( "This method can only be called within the context of an active Web Request.", action); }
public void RegisterForDisposal_WithValidArgumentsInHttpContext_Succeeds() { // Arrange ScopedLifestyle lifestyle = new WebRequestLifestyle(); var validContainer = new Container(); IDisposable validInstance = new DisposableCommand(); using (new HttpContextScope()) { // Act lifestyle.RegisterForDisposal(validContainer, validInstance); } }
public void RegisterForDisposal_OutsideTheContextOfAHttpRequest_ThrowsExpectedException() { // Arrange ScopedLifestyle lifestyle = new WebRequestLifestyle(); var validContainer = new Container(); var validInstance = new DisposableCommand(); // Act Action action = () => lifestyle.RegisterForDisposal(validContainer, validInstance); // Assert AssertThat.ThrowsWithExceptionMessageContains<InvalidOperationException>( "This method can only be called within the context of an active Web Request.", action); }