public void ReturnServiceScope_WhenServiceScopeWasSet()
        {
            var original = new ServiceCollection().BuildServiceProvider()
                           .CreateScope();

            context.Environment.Add(OwinContextExtensions.PerRequestServiceScopeKey, original);

            var serviceScope = context.GetDependencyScope();

            Assert.AreSame(original, serviceScope);
        }
 internal static void SetDependencyScope(this IOwinContext context, IServiceScope serviceScope)
 {
     if (context.GetDependencyScope() == null)
     {
         context.Environment.Add(PerRequestServiceScopeKey, serviceScope);
     }
 }
Esempio n. 3
0
        public void ReturnNull_WhenNoServiceScopeWasSetYet()
        {
            IServiceScope serviceScope = context.GetDependencyScope();

            Assert.IsNull(serviceScope);
        }