public void CreateScopeWhenRequestDoesNotExists() { Assert.Null(HttpContextSource.Current?.GetScope()); var container = ServiceScopeContainer.GetRequestOrCreateScope(); Assert.True(container.ShouldDispose); }
public void UseRequestScopeWhenPossible() { var scope = Globals.DependencyProvider.CreateScope(); HttpContextHelper.RegisterMockHttpContext(); HttpContextSource.Current.SetScope(scope); Assert.NotNull(HttpContextSource.Current?.GetScope()); var container = ServiceScopeContainer.GetRequestOrCreateScope(); Assert.False(container.ShouldDispose); Assert.AreEqual(scope, container.ServiceScope); }