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