public OwinRequestScopeContextFixture() { _owinEnvironment = new Dictionary <string, object> { { "the meaning of life, the universe, and everything", 42 } }; _items = A.Fake <IInternalOwinRequestScopeContextItems>(); _sut = new OwinRequestScopeContext(_owinEnvironment, _items, OwinRequestScopeContextOptions.Default); }
public async Task Invoke(IDictionary <string, object> environment) { if (OwinRequestScopeContext.Current != null) { throw new InvalidOperationException($"There is already an {OwinRequestScopeContext.Current.GetType().Name} for the current request scope."); } var keyComparer = _options?.ItemKeyEqualityComparer ?? OwinRequestScopeContextOptions.Default.ItemKeyEqualityComparer; using (var scopeContext = new OwinRequestScopeContext( environment, new OwinRequestScopeContextItems(keyComparer), _options ?? OwinRequestScopeContextOptions.Default)) { OwinRequestScopeContext.Current = scopeContext; if (_next != null) { await _next.Invoke(environment).ConfigureAwait(false); } } }