public async void BulkInsert_No_Errors() { TicketStatusControllerMockFacade mock = new TicketStatusControllerMockFacade(); var mockResponse = new CreateResponse <ApiTicketStatusResponseModel>(new FluentValidation.Results.ValidationResult()); mockResponse.SetRecord(new ApiTicketStatusResponseModel()); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiTicketStatusRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiTicketStatusResponseModel> >(mockResponse)); TicketStatusController controller = new TicketStatusController(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 <ApiTicketStatusRequestModel>(); records.Add(new ApiTicketStatusRequestModel()); 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 <ApiTicketStatusResponseModel>; result.Should().NotBeEmpty(); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiTicketStatusRequestModel>())); }
public async void BulkInsert_Errors() { TicketStatusControllerMockFacade mock = new TicketStatusControllerMockFacade(); var mockResponse = new Mock <CreateResponse <ApiTicketStatusServerResponseModel> >(null as ApiTicketStatusServerResponseModel); mockResponse.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiTicketStatusServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiTicketStatusServerResponseModel> >(mockResponse.Object)); TicketStatusController controller = new TicketStatusController(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 <ApiTicketStatusServerRequestModel>(); records.Add(new ApiTicketStatusServerRequestModel()); 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 <ApiTicketStatusServerRequestModel>())); }