コード例 #1
0
        public async Task GetFundingSchemaByVersion_WhenSchemaRetrivedFromBlobStorgae_ReturnsOkResult()
        {
            //arrange
            const string schema = "schema";

            const string version = "0.6";

            string blobName = $"{fundingSchemaFolder}/{version}.json";

            IFundingSchemaRepository fundingSchemaRepository = CreateFundingSchemaRepository();

            fundingSchemaRepository
            .SchemaVersionExists(Arg.Is(blobName))
            .Returns(true);

            fundingSchemaRepository
            .GetFundingSchemaVersion(Arg.Is(blobName))
            .Returns(schema);

            ILogger logger = CreateLogger();

            FundingSchemaService fundingSchemaService = CreateFundingSchemaService(logger, fundingSchemaRepository: fundingSchemaRepository);

            //Act
            IActionResult result = await fundingSchemaService.GetFundingSchemaByVersion(version);

            //Assert
            result
            .Should()
            .BeAssignableTo <OkObjectResult>()
            .Which
            .Value
            .Should()
            .Be(schema);
        }
コード例 #2
0
        public async Task GetFundingSchemaByVersion_WhenCheckingAlreadyExistsThrowsException_ReturnsInternalServerError()
        {
            //arrange
            const string version = "0.6";

            string blobName = $"{fundingSchemaFolder}/{version}.json";

            IFundingSchemaRepository fundingSchemaRepository = CreateFundingSchemaRepository();

            fundingSchemaRepository
            .When(x => x.SchemaVersionExists(Arg.Any <string>()))
            .Do(x => { throw new Exception(); });

            ILogger logger = CreateLogger();

            FundingSchemaService fundingSchemaService = CreateFundingSchemaService(logger, fundingSchemaRepository: fundingSchemaRepository);

            //Act
            IActionResult result = await fundingSchemaService.GetFundingSchemaByVersion(version);

            //Assert
            result
            .Should()
            .BeAssignableTo <InternalServerErrorResult>()
            .Which
            .Value
            .Should()
            .Be($"Error occurred fetching funding schema verion '{version}'");

            logger
            .Received(1)
            .Error(Arg.Is($"Failed to check if funding schema version: '{blobName}' exists"));
        }
コード例 #3
0
        public async Task GetFundingSchemaByVersion_GivenASchemaVersionThatDoesNotRxistInBlobStorage_ReturnsNotFound()
        {
            //Arrange
            const string version = "0.6";

            string blobName = $"{fundingSchemaFolder}/{version}.json";

            IFundingSchemaRepository fundingSchemaRepository = CreateFundingSchemaRepository();

            fundingSchemaRepository
            .SchemaVersionExists(Arg.Is(blobName))
            .Returns(false);

            FundingSchemaService fundingSchemaService = CreateFundingSchemaService(fundingSchemaRepository: fundingSchemaRepository);

            //Act
            IActionResult result = await fundingSchemaService.GetFundingSchemaByVersion(version);

            //Assert
            result
            .Should()
            .BeAssignableTo <NotFoundResult>();
        }
コード例 #4
0
        public async Task GetFundingSchemaByVersion_WhenEmptyStringRetrivedFromBlobStorgae_ReturnsInternalServerError()
        {
            //arrange
            const string version = "0.6";

            string blobName = $"{fundingSchemaFolder}/{version}.json";

            IFundingSchemaRepository fundingSchemaRepository = CreateFundingSchemaRepository();

            fundingSchemaRepository
            .SchemaVersionExists(Arg.Is(blobName))
            .Returns(true);

            fundingSchemaRepository
            .GetFundingSchemaVersion(Arg.Is(blobName))
            .Returns(string.Empty);

            ILogger logger = CreateLogger();

            FundingSchemaService fundingSchemaService = CreateFundingSchemaService(logger, fundingSchemaRepository: fundingSchemaRepository);

            //Act
            IActionResult result = await fundingSchemaService.GetFundingSchemaByVersion(version);

            //Assert
            result
            .Should()
            .BeAssignableTo <InternalServerErrorResult>()
            .Which
            .Value
            .Should()
            .Be($"Failed to retrive blob contents for funding schema version '{version}'");

            logger
            .Received(1)
            .Error(Arg.Is($"Empty schema returned from blob storage for blob name '{blobName}'"));
        }