コード例 #1
0
        public void GetControllerSessionBehaviorGuardClauses()
        {
            // Arrange
            RequestContext     requestContext = new RequestContext(new Mock <HttpContextBase>().Object, new RouteData());
            IControllerFactory factory        = new DefaultControllerFactory();

            // Act & Assert
            Assert.ThrowsArgumentNull(
                () => factory.GetControllerSessionBehavior(null, "controllerName"),
                "requestContext"
                );
            Assert.ThrowsArgumentNullOrEmpty(
                () => factory.GetControllerSessionBehavior(requestContext, null),
                "controllerName"
                );
            Assert.ThrowsArgumentNullOrEmpty(
                () => factory.GetControllerSessionBehavior(requestContext, ""),
                "controllerName"
                );
        }
コード例 #2
0
        public void GetControllerSessionBehaviorReturnsAttributeValueFromController()
        {
            // Arrange
            var factory = new DefaultControllerFactory();

            // Act
            SessionStateBehavior result = factory.GetControllerSessionBehavior(null, typeof(MyReadOnlyController));

            // Assert
            Assert.Equal(SessionStateBehavior.ReadOnly, result);
        }
コード例 #3
0
        public void GetControllerSessionBehaviorReturnsDefaultForControllerWithoutAttribute()
        {
            // Arrange
            var factory = new DefaultControllerFactory();

            // Act
            SessionStateBehavior result = factory.GetControllerSessionBehavior(null, typeof(object));

            // Assert
            Assert.Equal(SessionStateBehavior.Default, result);
        }
コード例 #4
0
        public void GetControllerSessionBehaviorReturnsDefaultForNullControllerType()
        {
            // Arrange
            var factory = new DefaultControllerFactory();

            // Act
            SessionStateBehavior result = factory.GetControllerSessionBehavior(null, null);

            // Assert
            Assert.Equal(SessionStateBehavior.Default, result);
        }
コード例 #5
0
        public void GetControllerSessionBehaviorReturnsAttributeValueFromController()
        {
            // Arrange
            var factory = new DefaultControllerFactory();

            // Act
            SessionStateBehavior result = factory.GetControllerSessionBehavior(null, typeof(MyReadOnlyController));

            // Assert
            Assert.Equal(SessionStateBehavior.ReadOnly, result);
        }
コード例 #6
0
        public void GetControllerSessionBehaviorReturnsDefaultForControllerWithoutAttribute()
        {
            // Arrange
            var factory = new DefaultControllerFactory();

            // Act
            SessionStateBehavior result = factory.GetControllerSessionBehavior(null, typeof(object));

            // Assert
            Assert.Equal(SessionStateBehavior.Default, result);
        }
コード例 #7
0
        public void GetControllerSessionBehaviorReturnsDefaultForNullControllerType()
        {
            // Arrange
            var factory = new DefaultControllerFactory();

            // Act
            SessionStateBehavior result = factory.GetControllerSessionBehavior(null, null);

            // Assert
            Assert.Equal(SessionStateBehavior.Default, result);
        }
コード例 #8
0
        public void GetControllerSessionBehaviorGuardClauses()
        {
            // Arrange
            RequestContext requestContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData());
            IControllerFactory factory = new DefaultControllerFactory();

            // Act & Assert
            Assert.ThrowsArgumentNull(
                () => factory.GetControllerSessionBehavior(null, "controllerName"),
                "requestContext"
                );
            Assert.ThrowsArgumentNullOrEmpty(
                () => factory.GetControllerSessionBehavior(requestContext, null),
                "controllerName"
                );
            Assert.ThrowsArgumentNullOrEmpty(
                () => factory.GetControllerSessionBehavior(requestContext, ""),
                "controllerName"
                );
        }