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