示例#1
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());
        }
示例#2
0
        /// <inheritdoc />
        public IAndActionResultTestBuilder <TActionResult> ActionAttributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.TestContext.MethodAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this.Builder);
        }
示例#3
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);
        }
示例#4
0
        /// <inheritdoc />
        public IBaseTestBuilderWithViewComponent Attributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.ViewComponentAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this);
        }
示例#5
0
        /// <inheritdoc />
        public IAndViewComponentResultTestBuilder <TInvocationResult> Attributes(int?withTotalNumberOf = null)
        {
            AttributesValidator.ValidateNumberOfAttributes(
                this.TestContext.ComponentAttributes,
                this.ThrowNewAttributeAssertionException,
                withTotalNumberOf);

            return(this.Builder);
        }
示例#6
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");
        }
示例#7
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");
        }
示例#8
0
        public void ValidateAnyNumberOfAttributesShouldNotFailWithExpectedNumberOfAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new MvcController());

            AttributesValidator.ValidateNumberOfAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres(), 2);
        }
        public void ValidateAnyNumberOfAttributesShouldFailWithNoAttributes()
        {
            var attributes = Reflection.GetCustomAttributes(new UserBuilder());

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