MyTested.AspNetCore.Mvc
MyTested.AspNetCore.Mvc copied to clipboard
Extend Fluent API to support adding ModelState
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:
- Entry with key "RequiredString" and a value of "Some Error"
- Entry with key "Integer" and a value of "Another Error"