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