public void it_should_dispose_the_current_context_when_it_is_not_null() { ContextManager sut = new ContextManagerBuilder(); var initialContext = sut.GetCurrentContext<MoviesContext>(); sut.Invoking(x => x.ReleaseContext()).ShouldNotThrow(); Thread.Sleep(2000); initialContext.Invoking(x => x.GetValidationErrors()) .ShouldThrow<InvalidOperationException>() .WithMessage("The operation cannot be completed because the DbContext has been disposed.", ComparisonMode.Exact); }
public void it_should_not_throw_an_exception_if_the_current_context_is_null() { ContextManager sut = new ContextManagerBuilder(); sut.Invoking(x => x.ReleaseContext()).ShouldNotThrow(); }