Example #1
0
        public async void BulkInsert_No_Errors()
        {
            KeyAllocationControllerMockFacade mock = new KeyAllocationControllerMockFacade();

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

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

            records.Add(new ApiKeyAllocationRequestModel());
            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 <ApiKeyAllocationResponseModel>;

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