示例#1
0
        public async void BulkInsert_No_Errors()
        {
            StateControllerMockFacade mock = new StateControllerMockFacade();

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

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

            records.Add(new ApiStateRequestModel());
            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 <ApiStateResponseModel>;

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