0

I create an "invalid" restaurant in my test and pass it to the Post method. In the Post method I validate the modelstate and it says it is valid. Any help is appreciated!

Domain Class:

[Required]
    public string Name { get; set; }

Test:

var invalidRestaurant = new Restaurant { City = "TEST", Id =1 };
var actionResult = _sut.Post(invalidRestaurant) as BadRequestResult;
Assert.NotNull(actionResult);

ModelState if-statement that doesn't get entered:

if (!ModelState.IsValid)
        {
            return BadRequest();
        }

0 Answers0