public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException()
 {
     var mockHttpApplication = new MockHttpApplication(null, false);
     mockHttpApplication.BeginRequest();
     var exception = Assert.Throws<InvalidOperationException>(() => serviceContainer.GetInstance<IFoo>());
     Assert.Contains("Unable to locate a scope manager for the current HttpRequest.", exception.Message);            
 }
Exemple #2
0
        public void ShouldHandleNullApplication()
        {
            var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), true);

            mockHttpApplication.BeginRequest();
            mockHttpApplication.EndRequest();
        }
Exemple #3
0
 public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException()
 {
     var mockHttpApplication = new MockHttpApplication(null);        
     mockHttpApplication.BeginRequest();            
     ExceptionAssert.Throws<InvalidOperationException>(
         () => serviceContainer.GetInstance<IFoo>(),
         e => e.ToString().Contains("Unable to locate a scope manager for the current HttpRequest."));
 }
Exemple #4
0
        public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException()
        {
            var mockHttpApplication = new MockHttpApplication(null, false);

            mockHttpApplication.BeginRequest();
            var exception = Assert.Throws <InvalidOperationException>(() => serviceContainer.GetInstance <IFoo>());

            Assert.Contains("Unable to locate a scope manager for the current HttpRequest.", exception.Message);
        }
Exemple #5
0
 private static IFoo GetInstanceWithinWebRequest()
 {
     var mockHttpApplication = new MockHttpApplication();
     mockHttpApplication.BeginRequest();
     IFoo firstInstance = serviceContainer.GetInstance<IFoo>();
     mockHttpApplication.EndRequest();
     mockHttpApplication.Dispose();
     return firstInstance;
 }
        public void GetInstance_WithoutBeginRequest_ThrowsMeaningfulException()
        {
            var mockHttpApplication = new MockHttpApplication(null);

            mockHttpApplication.BeginRequest();
            ExceptionAssert.Throws <InvalidOperationException>(
                () => serviceContainer.GetInstance <IFoo>(),
                e => e.ToString().Contains("Unable to locate a scope manager for the current HttpRequest."));
        }
 private static IFoo GetInstanceWithinWebRequest()
 {
     serviceContainer.EnablePerWebRequestScope();
     var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), false);
     mockHttpApplication.BeginRequest();
     IFoo firstInstance = serviceContainer.GetInstance<IFoo>();
     mockHttpApplication.EndRequest();
     mockHttpApplication.Dispose();
     return firstInstance;
 }        
Exemple #8
0
        private static IFoo GetInstanceWithinWebRequest()
        {
            var mockHttpApplication = new MockHttpApplication();

            mockHttpApplication.BeginRequest();
            IFoo firstInstance = serviceContainer.GetInstance <IFoo>();

            mockHttpApplication.EndRequest();
            mockHttpApplication.Dispose();
            return(firstInstance);
        }
Exemple #9
0
        private static IFoo GetInstanceWithinWebRequest()
        {
            serviceContainer.EnablePerWebRequestScope();
            var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), false);

            mockHttpApplication.BeginRequest();
            IFoo firstInstance = serviceContainer.GetInstance <IFoo>();

            mockHttpApplication.EndRequest();
            mockHttpApplication.Dispose();
            return(firstInstance);
        }
Exemple #10
0
        public void GetInstance_InsideWebRequest_ReturnsSameInstance()
        {                                                         
            var mockHttpApplication = new MockHttpApplication();                                    
            mockHttpApplication.BeginRequest();

            var firstInstance = serviceContainer.GetInstance<IFoo>();
            var secondInstance = serviceContainer.GetInstance<IFoo>();

            Assert.AreEqual(firstInstance, secondInstance);

            mockHttpApplication.EndRequest();
        }
Exemple #11
0
        public void GetInstance_InsideWebRequest_ReturnsSameInstance()
        {
            var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), false);

            mockHttpApplication.BeginRequest();

            var firstInstance  = serviceContainer.GetInstance <IFoo>();
            var secondInstance = serviceContainer.GetInstance <IFoo>();

            Assert.Equal(firstInstance, secondInstance);

            mockHttpApplication.EndRequest();
        }
 public void ShouldHandleNullApplication()
 {
     var mockHttpApplication = new MockHttpApplication(new LightInjectHttpModule(), true);
     mockHttpApplication.BeginRequest();            
     mockHttpApplication.EndRequest();
 }