Exemplo n.º 1
0
        public async Task Assemble_GivenSpecificationWithTwoFundingStreamsButTemplateContentsNotFoundForOneFundingStream_ReturnsCollectionWithOneItem()
        {
            //Arrange
            TemplateMetadataContents templateMetadataContents = new TemplateMetadataContents();

            SpecificationSummary specificationSummary = CreateSpecificationSummary();

            IPoliciesApiClient policiesApiClient = CreatePoliciesClient();

            policiesApiClient
            .GetFundingTemplateContents(Arg.Is("fs-1"), Arg.Is("fp-1"), Arg.Is("1.0"))
            .Returns(new ApiResponse <TemplateMetadataContents>(HttpStatusCode.OK, templateMetadataContents));
            policiesApiClient
            .GetFundingTemplateContents(Arg.Is("fs-2"), Arg.Is("fp-1"), Arg.Is("1.0"))
            .Returns((ApiResponse <TemplateMetadataContents>)null);

            TemplateMetadataContentsAssemblerService templateMetadataContentsAssemblerService = CreateService(policiesApiClient: policiesApiClient);

            //Act
            var templateMetadataContentsCollection = await templateMetadataContentsAssemblerService.Assemble(specificationSummary);

            //Assert
            templateMetadataContentsCollection
            .Should()
            .HaveCount(1);

            templateMetadataContentsCollection
            .First().Value
            .Should()
            .Be(templateMetadataContents);
        }
Exemplo n.º 2
0
        public async Task Assemble_GivenSpecificationWithTwoFundingStreamsAndTemplatesFound_ReturnsCollectionWithTwoItems()
        {
            //Arrange
            TemplateMetadataContents templateMetadataContentsFs1 = new TemplateMetadataContents();
            TemplateMetadataContents templateMetadataContentsFs2 = new TemplateMetadataContents();

            SpecificationSummary specificationSummary = CreateSpecificationSummary();

            IPoliciesApiClient policiesApiClient = CreatePoliciesClient();

            policiesApiClient
            .GetFundingTemplateContents(Arg.Is("fs-1"), Arg.Is("fp-1"), Arg.Is("1.0"))
            .Returns(new ApiResponse <TemplateMetadataContents>(HttpStatusCode.OK, templateMetadataContentsFs1));
            policiesApiClient
            .GetFundingTemplateContents(Arg.Is("fs-2"), Arg.Is("fp-1"), Arg.Is("1.0"))
            .Returns(new ApiResponse <TemplateMetadataContents>(HttpStatusCode.OK, templateMetadataContentsFs2));

            TemplateMetadataContentsAssemblerService templateMetadataContentsAssemblerService = CreateService(policiesApiClient: policiesApiClient);

            //Act
            var templateMetadataContentsCollection = await templateMetadataContentsAssemblerService.Assemble(specificationSummary);

            //Assert
            templateMetadataContentsCollection
            .Should()
            .HaveCount(2);
        }
Exemplo n.º 3
0
        public async Task Assemble_GivenSpecificationTemplateIdsDoesNotContainFundingStreamsAssigned_ReturnsEmptyCollection()
        {
            //Arrange
            SpecificationSummary specificationSummary = CreateSpecificationSummary();

            specificationSummary.TemplateIds = new Dictionary <string, string>();

            ILogger logger = CreateLogger();

            TemplateMetadataContentsAssemblerService templateMetadataContentsAssemblerService = CreateService(logger: logger);

            //Act
            var templateMetadataContents = await templateMetadataContentsAssemblerService.Assemble(specificationSummary);

            //Assert
            templateMetadataContents
            .Should()
            .BeEmpty();

            logger
            .Received(2)
            .Error(Arg.Any <string>());
        }