예제 #1
0
        public async void BulkInsert_No_Errors()
        {
            ChannelControllerMockFacade mock = new ChannelControllerMockFacade();

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

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

            records.Add(new ApiChannelRequestModel());
            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 <ApiChannelResponseModel>;

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