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

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

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

            records.Add(new ApiStoreRequestModel());
            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 <ApiStoreResponseModel>;

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