public void ValidateAttributesShouldWorkCorrectly() { var attributes = Reflection.GetCustomAttributes(new WebApiController()); AttributesValidator.ValidateAttributes( attributes, new ActionAttributesTestBuilder(new WebApiController(), "Test"), TestObjectFactory.GetFailingValidationActionWithTwoParameteres()); }
/// <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); }
/// <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()); }
/// <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); }
/// <inheritdoc /> public IBaseTestBuilderWithViewComponent Attributes(Action <IViewComponentAttributesTestBuilder> attributesTestBuilder) { var newAttributesTestBuilder = new ViewComponentAttributesTestBuilder(this.TestContext); attributesTestBuilder(newAttributesTestBuilder); AttributesValidator.ValidateAttributes( this.ViewComponentAttributes, newAttributesTestBuilder, this.ThrowNewAttributeAssertionException); return(this); }
/// <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); }