MyTested.AspNetCore.Mvc icon indicating copy to clipboard operation
MyTested.AspNetCore.Mvc copied to clipboard

Extend Fluent API to support adding ModelState

Open HristoHentov opened this issue 5 years ago • 0 comments

We can extend the support for adding errors to the test's model state, with the following extension to the API.

 MyController<MvcController>
    .Instance()
    .WithModelState(modelState => modelState
        .For<RequestModel>()
        .WithErrorFor(m => m.RequiredString, "Some Error")
        .WithErrorFor(m => m.Integer, "Another Error"))

This should add to the current model state's dictionary the following 2 entries:

  1. Entry with key "RequiredString" and a value of "Some Error"
  2. Entry with key "Integer" and a value of "Another Error"

HristoHentov avatar Dec 08 '19 19:12 HristoHentov