コード例 #1
0
        public void TestDeleteValueFromHttpContext()
        {
            // arrange
            this.InitialTestHttpContext();
            using (var httpContextLifetimeManger = new HttpContextLifetimeManager<TestingController>())
            {
                var testingController = new TestingController();

                // act
                httpContextLifetimeManger.SetValue(testingController);
                httpContextLifetimeManger.RemoveValue();
                object controllerFromHttpContext = httpContextLifetimeManger.GetValue();

                // assert
                Assert.Null(controllerFromHttpContext);
            }
        }
コード例 #2
0
        public void TestDeleteValueFromHttpContext()
        {
            // arrange
            this.InitialTestHttpContext();
            using (var httpContextLifetimeManger = new HttpContextLifetimeManager <TestingController>())
            {
                var testingController = new TestingController();

                // act
                httpContextLifetimeManger.SetValue(testingController);
                httpContextLifetimeManger.RemoveValue();
                object controllerFromHttpContext = httpContextLifetimeManger.GetValue();

                // assert
                Assert.Null(controllerFromHttpContext);
            }
        }
コード例 #3
0
        public void TestSetValueAndSetValueFromHttpContext()
        {
            // arrange
            this.InitialTestHttpContext();
            using (var httpContextLifetimeManger = new HttpContextLifetimeManager<TestingController>())
            {
                var testingController = new TestingController();

                // act
                httpContextLifetimeManger.SetValue(testingController);
                object controllerFromHttpContext = httpContextLifetimeManger.GetValue();

                // assert
                Assert.NotNull(controllerFromHttpContext);
                Assert.IsType<TestingController>(controllerFromHttpContext);
                Assert.Same(testingController, controllerFromHttpContext);
            }
        }
コード例 #4
0
        public void TestSetValueAndSetValueFromHttpContext()
        {
            // arrange
            this.InitialTestHttpContext();
            using (var httpContextLifetimeManger = new HttpContextLifetimeManager <TestingController>())
            {
                var testingController = new TestingController();

                // act
                httpContextLifetimeManger.SetValue(testingController);
                object controllerFromHttpContext = httpContextLifetimeManger.GetValue();

                // assert
                Assert.NotNull(controllerFromHttpContext);
                Assert.IsType <TestingController>(controllerFromHttpContext);
                Assert.Same(testingController, controllerFromHttpContext);
            }
        }