public async void PostDocumentModelStateErrorReturnsBadRequest() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new DocumentsController(context, _mapper)) { controller.ModelState.AddModelError("an error", "some error"); DocumentDto a101 = GetTestDocumentDto(101); var result = await controller.PostDocument(a101); Assert.IsType <BadRequestObjectResult>(result); } }
public async void PostDocumentCorrectDataCreatesDocument() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new DocumentsController(context, _mapper)) { DocumentDto a101 = GetTestDocumentDto(101); var result = await controller.PostDocument(a101); Assert.NotNull(result); var resultValue = Assert.IsType <CreatedAtActionResult>(result); } }