public async Task DeleteAll_Ok() { var testDomains = TestData.TestResultDomains; var testService = DatabaseServiceDeleteMock.GetTestDatabaseTable(testDomains); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var actionResult = await testController.Delete(); Assert.IsType <NoContentResult>(actionResult); var noContentResult = (NoContentResult)actionResult; Assert.Equal(StatusCodes.Status204NoContent, noContentResult.StatusCode); }
public async Task Delete_Ok() { var testDomains = TestData.TestResultDomains; var testDelete = testDomains.Value.Last(); var testDeleteId = testDelete.Id; var testService = DatabaseServiceDeleteMock.GetTestDatabaseTable(testDomains); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var actionResult = await testController.Delete(testDeleteId); var testsAfter = testTransferConverter.FromTransfer(actionResult.Value); Assert.True(testsAfter.Value.Equals(testDelete)); }
public async Task Delete_NotFound() { var testDomains = TestData.TestResultDomains; var testDelete = testDomains.Value.Last(); var testDeleteId = testDelete.Id; var testService = DatabaseServiceDeleteMock.GetTestDatabaseTable(testDomains, DatabaseServiceDeleteMock.DeleteNotFoundFunc()); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var actionResult = await testController.Delete(testDeleteId); Assert.IsType <NotFoundResult>(actionResult.Result); var notFoundResult = (NotFoundResult)actionResult.Result; Assert.Equal(StatusCodes.Status404NotFound, notFoundResult.StatusCode); }
public async Task DeleteAll_ErrorDatabase() { var initialError = ErrorData.DatabaseError; var testResult = new ResultError(initialError); var testDomains = TestData.TestResultDomains; var testService = DatabaseServiceDeleteMock.GetTestDatabaseTable(testDomains, testResult); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var actionResult = await testController.Delete(); Assert.IsType <BadRequestObjectResult>(actionResult); var badRequest = (BadRequestObjectResult)actionResult; var errors = (SerializableError)badRequest.Value; Assert.Equal(StatusCodes.Status400BadRequest, badRequest.StatusCode); Assert.Equal(initialError.ErrorResultType.ToString(), errors.Keys.First()); }