Пример #1
0
        /// <summary>
        /// Checks whether the tested controller has no attributes of any type.
        /// </summary>
        /// <returns>Base test builder.</returns>
        public IBaseTestBuilder NoAttributes()
        {
            AttributesValidator.ValidateNoAttributes(
                this.ControllerLevelAttributes,
                this.ThrowNewAttributeAssertionException);

            return(this);
        }
Пример #2
0
        /// <summary>
        /// Checks whether the tested action has no attributes of any type.
        /// </summary>
        /// <returns>Test builder with AndAlso method.</returns>
        public IAndTestBuilder <TActionResult> NoActionAttributes()
        {
            AttributesValidator.ValidateNoAttributes(
                this.ActionLevelAttributes,
                this.ThrowNewAttributeAssertionException);

            return(this.NewAndTestBuilder());
        }
Пример #3
0
        /// <inheritdoc />
        public IBaseTestBuilderWithViewComponent NoAttributes()
        {
            AttributesValidator.ValidateNoAttributes(
                this.ViewComponentAttributes,
                this.ThrowNewAttributeAssertionException);

            return(this);
        }
Пример #4
0
        /// <inheritdoc />
        public IAndActionResultTestBuilder <TActionResult> NoActionAttributes()
        {
            AttributesValidator.ValidateNoAttributes(
                this.TestContext.MethodAttributes,
                this.ThrowNewAttributeAssertionException);

            return(this.Builder);
        }
Пример #5
0
        /// <inheritdoc />
        public IAndViewComponentResultTestBuilder <TInvocationResult> NoAttributes()
        {
            AttributesValidator.ValidateNoAttributes(
                this.TestContext.ComponentAttributes,
                this.ThrowNewAttributeAssertionException);

            return(this.Builder);
        }
Пример #6
0
        /// <inheritdoc />
        public IAndViewComponentResultTestBuilder <TInvocationResult> Attributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.TestContext.ComponentAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this.Builder);
        }
Пример #7
0
        /// <summary>
        /// Checks whether the tested controller has at least 1 attribute of any type.
        /// </summary>
        /// <param name="withTotalNumberOf">Optional parameter specifying the exact total number of attributes on the tested controller.</param>
        /// <returns>Base test builder.</returns>
        public IBaseTestBuilder Attributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.ControllerLevelAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this);
        }
Пример #8
0
        public void ValidateAttributesShouldWorkCorrectly()
        {
            var attributes = Reflection.GetCustomAttributes(new WebApiController());

            AttributesValidator.ValidateAttributes(
                attributes,
                new ActionAttributesTestBuilder(new WebApiController(), "Test"),
                TestObjectFactory.GetFailingValidationActionWithTwoParameteres());
        }
Пример #9
0
        /// <summary>
        /// Checks whether the tested action has at least 1 attribute of any type.
        /// </summary>
        /// <param name="withTotalNumberOf">Optional parameter specifying the exact total number of attributes on the tested action.</param>
        /// <returns>Test builder with AndAlso method.</returns>
        public IAndTestBuilder <TActionResult> ActionAttributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.ActionLevelAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this.NewAndTestBuilder());
        }
Пример #10
0
        /// <inheritdoc />
        public IBaseTestBuilderWithViewComponent Attributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.ViewComponentAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this);
        }
Пример #11
0
        /// <inheritdoc />
        public IAndActionResultTestBuilder <TActionResult> ActionAttributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.TestContext.MethodAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this.Builder);
        }
Пример #12
0
        public void ValidateAnyNumberOfAttributesShouldFailWithIncorrectExpectedNumberOfAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new MvcController());

            Test.AssertException <NullReferenceException>(
                () =>
            {
                AttributesValidator.ValidateNumberOfAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres(), 3);
            },
                "have 3 attributes in fact found 2");
        }
Пример #13
0
        public void ValidateNoAttributesShouldFailWithAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new MvcController());

            Test.AssertException <NullReferenceException>(
                () =>
            {
                AttributesValidator.ValidateNoAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres());
            },
                "not have any attributes it had some");
        }
Пример #14
0
        public void ValidateAnyNumberOfAttributesShouldFailWithNoAttributes()
        {
            Test.AssertException <NullReferenceException>(
                () =>
            {
                var attributes = Reflection.GetCustomAttributes(new ClaimsPrincipalBuilder());

                AttributesValidator.ValidateNumberOfAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres());
            },
                "have at least 1 attribute in fact none was found");
        }
Пример #15
0
        /// <inheritdoc />
        public IBaseTestBuilderWithViewComponent Attributes(Action <IViewComponentAttributesTestBuilder> attributesTestBuilder)
        {
            var newAttributesTestBuilder = new ViewComponentAttributesTestBuilder(this.TestContext);

            attributesTestBuilder(newAttributesTestBuilder);

            AttributesValidator.ValidateAttributes(
                this.ViewComponentAttributes,
                newAttributesTestBuilder,
                this.ThrowNewAttributeAssertionException);

            return(this);
        }
Пример #16
0
        /// <inheritdoc />
        public IAndActionResultTestBuilder <TActionResult> ActionAttributes(Action <IActionAttributesTestBuilder> attributesTestBuilder)
        {
            var newAttributesTestBuilder = new ActionAttributesTestBuilder(this.TestContext);

            attributesTestBuilder(newAttributesTestBuilder);

            AttributesValidator.ValidateAttributes(
                this.TestContext.MethodAttributes,
                newAttributesTestBuilder,
                this.ThrowNewAttributeAssertionException);

            return(this.Builder);
        }
Пример #17
0
        /// <summary>
        /// Checks whether the tested action has at specific attributes.
        /// </summary>
        /// <param name="attributesTestBuilder">Builder for testing specific attributes on the action.</param>
        /// <returns>Test builder with AndAlso method.</returns>
        public IAndTestBuilder <TActionResult> ActionAttributes(Action <IActionAttributesTestBuilder> attributesTestBuilder)
        {
            var newAttributesTestBuilder = new ActionAttributesTestBuilder(this.Controller, this.ActionName);

            attributesTestBuilder(newAttributesTestBuilder);

            AttributesValidator.ValidateAttributes(
                this.ActionLevelAttributes,
                newAttributesTestBuilder,
                this.ThrowNewAttributeAssertionException);

            return(this.NewAndTestBuilder());
        }
Пример #18
0
        /// <summary>
        /// Checks whether the tested controller has at specific attributes.
        /// </summary>
        /// <param name="attributesTestBuilder">Builder for testing specific attributes on the controller.</param>
        /// <returns>Base test builder.</returns>
        public IBaseTestBuilder Attributes(Action <IControllerAttributesTestBuilder> attributesTestBuilder)
        {
            var newAttributesTestBuilder = new ControllerAttributesTestBuilder(this.Controller);

            attributesTestBuilder(newAttributesTestBuilder);

            AttributesValidator.ValidateAttributes(
                this.ControllerLevelAttributes,
                newAttributesTestBuilder,
                this.ThrowNewAttributeAssertionException);

            return(this);
        }
Пример #19
0
        /// <inheritdoc />
        public IAndViewComponentResultTestBuilder <TInvocationResult> Attributes(
            Action <IViewComponentAttributesTestBuilder> attributesTestBuilder)
        {
            var newAttributesTestBuilder = new ViewComponentAttributesTestBuilder(this.TestContext);

            attributesTestBuilder(newAttributesTestBuilder);

            AttributesValidator.ValidateAttributes(
                this.TestContext.ComponentAttributes,
                newAttributesTestBuilder,
                this.ThrowNewAttributeAssertionException);

            return(this.Builder);
        }
Пример #20
0
        public void ValidateNoAttributesShouldFailWithAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new WebApiController());

            AttributesValidator.ValidateNoAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres());
        }
Пример #21
0
        public void ValidateAnyNumberOfAttributesShouldFailWithNoAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new UserBuilder());

            AttributesValidator.ValidateNumberOfAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres());
        }
Пример #22
0
        public void ValidateNoAttributesShouldNotFailWithNoAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new ClaimsPrincipalBuilder());

            AttributesValidator.ValidateNoAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres());
        }
Пример #23
0
        public void ValidateAnyNumberOfAttributesShouldNotFailWithExpectedNumberOfAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new MvcController());

            AttributesValidator.ValidateNumberOfAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres(), 2);
        }