async public Task SaveFundingStream_GivenValidJsonAndSaveWasSuccesful_ReturnsOK()
        {
            //Arrange
            ILogger logger = CreateLogger();

            HttpStatusCode statusCode = HttpStatusCode.Created;

            IPolicyRepository policyRepository = CreatePolicyRepository();

            policyRepository
            .SaveFundingStream(Arg.Any <FundingStream>())
            .Returns(statusCode);

            FundingStreamService fundingStreamsService = CreateFundingStreamService(logger: logger, policyRepository: policyRepository);

            //Act
            IActionResult result = await fundingStreamsService.SaveFundingStream(CreateFundingStreamSaveModel());

            //Assert
            result
            .Should()
            .BeOfType <OkResult>();

            logger
            .Received(1)
            .Information(Arg.Is($"Successfully saved file to cosmos db"));
        }
        async public Task SaveFundingStream_GivenValidJsonButFailedToSaveToDatabase_ReturnsStatusCode()
        {
            //Arrange
            ILogger logger = CreateLogger();

            HttpStatusCode failedCode = HttpStatusCode.BadGateway;

            IPolicyRepository policyRepository = CreatePolicyRepository();

            policyRepository
            .SaveFundingStream(Arg.Any <FundingStream>())
            .Returns(failedCode);

            FundingStreamService fundingStreamsService = CreateFundingStreamService(logger: logger, policyRepository: policyRepository);

            //Act
            IActionResult result = await fundingStreamsService.SaveFundingStream(CreateFundingStreamSaveModel());

            //Assert
            result
            .Should()
            .BeOfType <StatusCodeResult>();

            StatusCodeResult statusCodeResult = (StatusCodeResult)result;

            statusCodeResult
            .StatusCode
            .Should()
            .Be(502);

            logger
            .Received(1)
            .Error(Arg.Is($"Failed to save to cosmos db with status 502"));
        }
        async public Task SaveFundingStream_GivenValidJsonButSavingToDatabaseThrowsException_ReturnsInternalServerError()
        {
            //Arrange
            ILogger logger = CreateLogger();

            IPolicyRepository policyRepository = CreatePolicyRepository();

            policyRepository
            .When(x => x.SaveFundingStream(Arg.Any <FundingStream>()))
            .Do(x => { throw new Exception(); });

            FundingStreamService fundingStreamsService = CreateFundingStreamService(logger: logger, policyRepository: policyRepository);

            string expectedErrorMessage = $"Exception occurred writing to json file to cosmos db";

            //Act
            IActionResult result = await fundingStreamsService.SaveFundingStream(CreateFundingStreamSaveModel());

            //Assert
            result
            .Should()
            .BeOfType <InternalServerErrorResult>()
            .Which
            .Value
            .Should()
            .Be(expectedErrorMessage);

            logger
            .Received(1)
            .Error(Arg.Any <Exception>(), Arg.Is(expectedErrorMessage));
        }
        async public Task SaveFundingStream_GivenNoJsonWasProvidedButFileNameWas_ReturnsBadRequest()
        {
            //Arrange
            ILogger logger = CreateLogger();

            FundingStreamService fundingStreamsService = CreateFundingStreamService(logger: logger);

            //Act
            IActionResult result = await fundingStreamsService.SaveFundingStream(null);

            //Assert
            result
            .Should()
            .BeOfType <BadRequestObjectResult>();

            logger
            .Received(1)
            .Error(Arg.Is($"Null or empty json provided for file"));
        }