コード例 #1
0
        public void Should_throw_ConfigurationErrorsException()
        {
            // Arrange
            var configurationExpression = new RootConfiguration();
            configurationExpression.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);
            configurationExpression.For<BlogController>(x => x.Index());

            // Assert
            Assert.Throws<ConfigurationErrorsException>(() => configurationExpression.GetRolesFrom(StaticHelper.GetRolesExcludingOwner));
        }
コード例 #2
0
        public void Should_have_policycontainer_for_TaskController_LongRunningJsonAction()
        {
            // Arrange
            var configurationExpression = new RootConfiguration();
            configurationExpression.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);

            // Act
            configurationExpression.For<TaskController>(x => x.LongRunningJsonAction());

            // Assert
            var policyContainer = configurationExpression.Runtime.PolicyContainers.First();

            Assert.That(policyContainer.ControllerName, Is.EqualTo(NameHelper.Controller<TaskController>()));
            Assert.That(policyContainer.ActionName, Is.EqualTo("LongRunningJsonAction"));
            Assert.That(configurationExpression.Runtime.PolicyContainers.Count(), Is.EqualTo(1));
        }
コード例 #3
0
        public void Should_have_policycontainer_for_all_actions_including_void_actions()
        {
            // Arrange
            var configurationExpression = new RootConfiguration();
            configurationExpression.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);

            // Act
            configurationExpression.For<ParentVoidActionController>();

            // Assert
            Assert.That(configurationExpression.Runtime.PolicyContainers.Count(), Is.EqualTo(2));
        }
コード例 #4
0
        public void Should_have_policycontainer_for_AliasedController_ActualAction()
        {
            // Arrange
            var configurationExpression = new RootConfiguration();
            configurationExpression.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);

            // Act
            configurationExpression.For<AliasedController>();

            // Assert
            var policyContainer = configurationExpression.Runtime.PolicyContainers.First();

            Assert.That(policyContainer.ActionName, Is.EqualTo("AliasedAction"));
            Assert.That(configurationExpression.Runtime.PolicyContainers.Count(), Is.EqualTo(1));
        }
コード例 #5
0
        public void Should_have_policycontainer_for_void_action_from_parent_controller()
        {
            // Arrange
            var configurationExpression = new RootConfiguration();
            configurationExpression.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);

            // Act
            configurationExpression.For<ChildVoidActionController>(x => x.VoidAction());

            // Assert
            Assert.That(configurationExpression.Runtime.PolicyContainers.Count(), Is.EqualTo(1));
        }