/// <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); }
/// <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()); }
/// <inheritdoc /> public IBaseTestBuilderWithViewComponent NoAttributes() { AttributesValidator.ValidateNoAttributes( this.ViewComponentAttributes, this.ThrowNewAttributeAssertionException); return(this); }
/// <inheritdoc /> public IAndActionResultTestBuilder <TActionResult> NoActionAttributes() { AttributesValidator.ValidateNoAttributes( this.TestContext.MethodAttributes, this.ThrowNewAttributeAssertionException); return(this.Builder); }
/// <inheritdoc /> public IAndViewComponentResultTestBuilder <TInvocationResult> NoAttributes() { AttributesValidator.ValidateNoAttributes( this.TestContext.ComponentAttributes, this.ThrowNewAttributeAssertionException); return(this.Builder); }
/// <inheritdoc /> public IAndViewComponentResultTestBuilder <TInvocationResult> Attributes(int?withTotalNumberOf = null) { AttributesValidator.ValidateNumberOfAttributes( this.TestContext.ComponentAttributes, 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); }
public void ValidateAttributesShouldWorkCorrectly() { var attributes = Reflection.GetCustomAttributes(new WebApiController()); AttributesValidator.ValidateAttributes( attributes, new ActionAttributesTestBuilder(new WebApiController(), "Test"), TestObjectFactory.GetFailingValidationActionWithTwoParameteres()); }
/// <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 IBaseTestBuilderWithViewComponent Attributes(int?withTotalNumberOf = null) { AttributesValidator.ValidateNumberOfAttributes( this.ViewComponentAttributes, this.ThrowNewAttributeAssertionException, withTotalNumberOf); return(this); }
/// <inheritdoc /> public IAndActionResultTestBuilder <TActionResult> ActionAttributes(int?withTotalNumberOf = null) { AttributesValidator.ValidateNumberOfAttributes( this.TestContext.MethodAttributes, 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 ValidateNoAttributesShouldFailWithAttributes() { var attributes = Reflection.GetCustomAttributes(new MvcController()); Test.AssertException <NullReferenceException>( () => { AttributesValidator.ValidateNoAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres()); }, "not have any attributes it had some"); }
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"); }
/// <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 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 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); }
public void ValidateNoAttributesShouldFailWithAttributes() { var attributes = Reflection.GetCustomAttributes(new WebApiController()); AttributesValidator.ValidateNoAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres()); }
public void ValidateAnyNumberOfAttributesShouldFailWithNoAttributes() { var attributes = Reflection.GetCustomAttributes(new UserBuilder()); AttributesValidator.ValidateNumberOfAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres()); }
public void ValidateNoAttributesShouldNotFailWithNoAttributes() { var attributes = Reflection.GetCustomAttributes(new ClaimsPrincipalBuilder()); AttributesValidator.ValidateNoAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres()); }
public void ValidateAnyNumberOfAttributesShouldNotFailWithExpectedNumberOfAttributes() { var attributes = Reflection.GetCustomAttributes(new MvcController()); AttributesValidator.ValidateNumberOfAttributes(attributes, TestObjectFactory.GetFailingValidationActionWithTwoParameteres(), 2); }