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