public async Task Post_Collection_Ok() { var testDomains = TestData.TestResultDomains; var testDomainsIds = TestData.GetTestIds(testDomains.Value); var testService = DatabaseServicePostMock.GetTestDatabaseTable(testDomains); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var testTransfers = testTransferConverter.ToTransfers(testDomains.Value).ToList(); var actionResult = await testController.Post(testTransfers); Assert.True(testDomainsIds.SequenceEqual(actionResult.Value)); }
public async Task Post_Value_Ok() { var testDomain = TestData.TestResultDomain; var testDomains = TestData.TestResultDomains; var testDomainsId = testDomain.Value.Id; var testService = DatabaseServicePostMock.GetTestDatabaseTable(testDomains); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var testTransfer = testTransferConverter.ToTransfer(testDomain.Value); var actionResult = await testController.Post(testTransfer); Assert.True(testDomainsId.Equals(actionResult.Value)); }
public async Task PostValue_NotFound() { var testDomains = TestData.TestResultDomains; var testPost = testDomains.Value.Last(); var testService = DatabaseServicePostMock.GetTestDatabaseTable(testDomains, DatabaseServicePostMock.PostValueFoundFunc()); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var testTransfer = testTransferConverter.ToTransfer(testPost); var actionResult = await testController.Post(testTransfer); Assert.IsType <NotFoundResult>(actionResult.Result); var notFoundResult = (NotFoundResult)actionResult.Result; Assert.Equal(StatusCodes.Status404NotFound, notFoundResult.StatusCode); }
public async Task Post_Collection_ErrorDatabase() { var initialError = ErrorData.DatabaseError; var testDomains = new ResultCollection <ITestDomain>(initialError); var testService = DatabaseServicePostMock.GetTestDatabaseTable(testDomains); var testTransferConverter = TestTransferConverterMock.TestTransferConverter; var testController = new TestController(testService.Object, testTransferConverter); var testTransfers = testTransferConverter.ToTransfers(testDomains.Value).ToList(); var actionResult = await testController.Post(testTransfers); Assert.IsType <BadRequestObjectResult>(actionResult.Result); var badRequest = (BadRequestObjectResult)actionResult.Result; var errors = (SerializableError)badRequest.Value; Assert.Equal(StatusCodes.Status400BadRequest, badRequest.StatusCode); Assert.Equal(initialError.ErrorResultType.ToString(), errors.Keys.First()); }