public async void BulkInsert_No_Errors() { CallDispositionControllerMockFacade mock = new CallDispositionControllerMockFacade(); var mockResponse = ValidationResponseFactory <ApiCallDispositionServerResponseModel> .CreateResponse(null as ApiCallDispositionServerResponseModel); mockResponse.SetRecord(new ApiCallDispositionServerResponseModel()); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiCallDispositionServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiCallDispositionServerResponseModel> >(mockResponse)); CallDispositionController controller = new CallDispositionController(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 <ApiCallDispositionServerRequestModel>(); records.Add(new ApiCallDispositionServerRequestModel()); 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 CreateResponse <List <ApiCallDispositionServerResponseModel> >; result.Success.Should().BeTrue(); result.Record.Should().NotBeEmpty(); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiCallDispositionServerRequestModel>())); }
public async void BulkInsert_Errors() { CallDispositionControllerMockFacade mock = new CallDispositionControllerMockFacade(); var mockResponse = new Mock <CreateResponse <ApiCallDispositionServerResponseModel> >(null as ApiCallDispositionServerResponseModel); mockResponse.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiCallDispositionServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiCallDispositionServerResponseModel> >(mockResponse.Object)); CallDispositionController controller = new CallDispositionController(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 <ApiCallDispositionServerRequestModel>(); records.Add(new ApiCallDispositionServerRequestModel()); 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 <ApiCallDispositionServerRequestModel>())); }