public async void BulkInsert_No_Errors() { FileTypeControllerMockFacade mock = new FileTypeControllerMockFacade(); var mockResponse = new CreateResponse <ApiFileTypeResponseModel>(new FluentValidation.Results.ValidationResult()); mockResponse.SetRecord(new ApiFileTypeResponseModel()); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiFileTypeRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiFileTypeResponseModel> >(mockResponse)); FileTypeController controller = new FileTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); var records = new List <ApiFileTypeRequestModel>(); records.Add(new ApiFileTypeRequestModel()); IActionResult response = await controller.BulkInsert(records); response.Should().BeOfType <OkObjectResult>(); (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK); var result = (response as OkObjectResult).Value as List <ApiFileTypeResponseModel>; result.Should().NotBeEmpty(); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiFileTypeRequestModel>())); }
public async void BulkInsert_Errors() { FileTypeControllerMockFacade mock = new FileTypeControllerMockFacade(); var mockResponse = new Mock <CreateResponse <ApiFileTypeServerResponseModel> >(null as ApiFileTypeServerResponseModel); mockResponse.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiFileTypeServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiFileTypeServerResponseModel> >(mockResponse.Object)); FileTypeController controller = new FileTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); var records = new List <ApiFileTypeServerRequestModel>(); records.Add(new ApiFileTypeServerRequestModel()); IActionResult response = await controller.BulkInsert(records); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiFileTypeServerRequestModel>())); }