コード例 #1
0
        public async void BulkInsert_No_Errors()
        {
            ProjectControllerMockFacade mock = new ProjectControllerMockFacade();

            var mockResponse = new CreateResponse <ApiProjectResponseModel>(new FluentValidation.Results.ValidationResult());

            mockResponse.SetRecord(new ApiProjectResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiProjectRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiProjectResponseModel> >(mockResponse));
            ProjectController controller = new ProjectController(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 <ApiProjectRequestModel>();

            records.Add(new ApiProjectRequestModel());
            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 <ApiProjectResponseModel>;

            result.Should().NotBeEmpty();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiProjectRequestModel>()));
        }