public async Task GetSpecificationWithResultsByFundingPeriodIdAndFundingStreamId_GivenResultsReturnedButOnlyOneHasProviderResults_ReturnsOKObjectWithOneSummary()
        {
            //Arrange
            string fundingStreamId  = NewRandomString();
            string fundingPeriodId  = NewRandomString();
            string specificationId1 = NewRandomString();
            string specificationId2 = NewRandomString();

            IMapper mapper = CreateImplementedMapper();

            IEnumerable <Specification> specifications = NewSpecifications(
                _ => _.WithId(specificationId1),
                _ => _.WithId(specificationId2));

            ILogger logger = CreateLogger();

            ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository();

            specificationsRepository
            .GetSpecificationsByFundingPeriodAndFundingStream(Arg.Is(FundingPeriodId), Arg.Is(FundingStreamId))
            .Returns(specifications);

            IResultsRepository resultsRepository = CreateResultsRepository();

            resultsRepository
            .SpecificationHasResults(Arg.Is(specificationId1))
            .Returns(true);

            resultsRepository
            .SpecificationHasResults(Arg.Is(specificationId2))
            .Returns(false);

            SpecificationsService service = CreateService(
                mapper: mapper,
                logs: logger,
                specificationsRepository: specificationsRepository,
                resultsRepository: resultsRepository);

            //Act
            IActionResult result = await service.GetSpecificationWithResultsByFundingPeriodIdAndFundingStreamId(FundingPeriodId, FundingStreamId);

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

            OkObjectResult okObjectResult = result as OkObjectResult;

            IEnumerable <SpecificationSummary> summaries = okObjectResult.Value as IEnumerable <SpecificationSummary>;

            summaries
            .Count()
            .Should()
            .Be(1);
        }
示例#2
0
        public async Task GetCurrentSpecificationsByFundingPeriodIdAndFundingStreamId_GivenFundingStreamIdAndFundingPeriodId_ReturnsSpecificationSummary()
        {
            string fundingStreamId = NewRandomString();
            string fundingPeriodId = NewRandomString();
            string specificationId = NewRandomString();

            IMapper mapper = CreateImplementedMapper();
            ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository();

            IEnumerable <Specification> specifications = NewSpecifications(_ => _.WithId(specificationId));

            specificationsRepository
            .GetSpecificationsByFundingPeriodAndFundingStream(fundingPeriodId, fundingStreamId)
            .Returns(specifications);

            SpecificationsService service = CreateService(
                mapper: mapper,
                specificationsRepository: specificationsRepository);

            IActionResult result = await service.GetCurrentSpecificationsByFundingPeriodIdAndFundingStreamId(fundingPeriodId, fundingStreamId);

            result
            .Should()
            .BeOfType <OkObjectResult>()
            .Which
            .Value
            .Should()
            .BeOfType <List <SpecificationSummary> >()
            .And
            .NotBeNull();

            List <SpecificationSummary> objContent           = (List <SpecificationSummary>)((OkObjectResult)result).Value;
            SpecificationSummary        specificationSummary = objContent.FirstOrDefault();

            specificationSummary
            .Should()
            .NotBeNull();

            specificationSummary
            .Id
            .Should()
            .Be(specificationId);
        }