public async Task Put_NotFound() { var testDomains = TestData.TestResultDomains; var testPut = testDomains.Value.Last(); var testService = DatabaseServicePutMock.GetTestDatabaseTable(testDomains, DatabaseServicePutMock.PutNotFoundFunc()); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var testTransfer = testTransferConverter.ToTransfer(testPut); var actionResult = await testController.Put(testTransfer); Assert.IsType <NotFoundResult>(actionResult); var notFoundResult = (NotFoundResult)actionResult; Assert.Equal(StatusCodes.Status404NotFound, notFoundResult.StatusCode); }
public async Task Put_ErrorDatabase() { var initialError = ErrorData.DatabaseError; var testDomains = new ResultCollection <ITestDomain>(initialError); var testPut = TestData.TestResultDomains.Value.Last(); var testService = DatabaseServicePutMock.GetTestDatabaseTable(testDomains); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var testTransfer = testTransferConverter.ToTransfer(testPut); var actionResult = await testController.Put(testTransfer); 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()); }