/// <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()); }
/// <inheritdoc /> public IAndActionResultTestBuilder <TActionResult> ActionAttributes(int?withTotalNumberOf = null) { AttributesValidator.ValidateNumberOfAttributes( this.TestContext.MethodAttributes, this.ThrowNewAttributeAssertionException, withTotalNumberOf); return(this.Builder); }
/// <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); }
/// <inheritdoc /> public IBaseTestBuilderWithViewComponent Attributes(int?withTotalNumberOf = null) { AttributesValidator.ValidateNumberOfAttributes( this.ViewComponentAttributes, this.ThrowNewAttributeAssertionException, withTotalNumberOf); return(this); }
/// <inheritdoc /> public IAndViewComponentResultTestBuilder <TInvocationResult> Attributes(int?withTotalNumberOf = null) { AttributesValidator.ValidateNumberOfAttributes( this.TestContext.ComponentAttributes, this.ThrowNewAttributeAssertionException, withTotalNumberOf); return(this.Builder); }
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"); }
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"); }
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()); }