public async Task ExecuteActionWithValidModelReturnsContent() { using (var server = this.CreateServer()) { var model = new ValidateModelAttributeFixtureModel() { Name = "test" }; var response = await server.Client.PostAsJsonAsync(this.rootRoute, model); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(model.Name, responseContent); } }
public async Task ExecuteActionWithInvalidModelReturnsModelState() { using (var server = this.CreateServer()) { var model = new ValidateModelAttributeFixtureModel() { Name = string.Empty }; var response = await server.Client.PostAsJsonAsync(this.rootRoute, model); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); var responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains("The name cannot be empty", responseContent); } }
public string Post(ValidateModelAttributeFixtureModel model) { return(model.Name); }
public string Post(ValidateModelAttributeFixtureModel model) { return model.Name; }