public async void DeleteDocumentWithIncorrectIdReturnsNotFound() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new DocumentsController(context, _mapper)) { var result = await controller.DeleteDocument(999); Assert.IsType <NotFoundResult>(result); } }
public async void DeleteDocumentModelStateErrorReturnsBadRequest() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new DocumentsController(context, _mapper)) { controller.ModelState.AddModelError("an error", "some error"); var result = await controller.DeleteDocument(1); Assert.IsType <BadRequestObjectResult>(result); } }
public async void DeleteDocumentIdDeletesDocument() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new DocumentsController(context, _mapper)) { var result = await controller.DeleteDocument(3); DocumentDto a3 = GetTestDocumentDtoFromContext(3); Assert.NotNull(result); var okObjectResult = Assert.IsType <OkObjectResult>(result); var resultValue = okObjectResult.Value; Assert.Equal(a3, resultValue); } }
public async Task DeleteDocumentHttpStatusOkTest() { var actual = await _documentsController.DeleteDocument(1) as NoContentResult; actual.StatusCode.Should().Equals(204); }