Пример #1
0
        public void GenerateAtomLinksForResultGivenBaseUrl_WhenOnAMiddlePage_ShouldReturnCorrectGeneratedValues()
        {
            // arrange
            SearchFeedV3 <string> SearchFeedV3 = new SearchFeedV3 <string>
            {
                Top        = 10,
                TotalCount = 50,
                PageRef    = 3
            };

            // act
            IList <AtomLink> atomLinksForFeed = SearchFeedV3.GenerateAtomLinksForResultGivenBaseUrl("https://localhost:5009/api/v2/allocations/notifications{0}");

            // assert
            atomLinksForFeed
            .Count
            .Should().Be(4);

            var atomLink1 = atomLinksForFeed.First();

            atomLink1
            .Href
            .Should().Be("https://localhost:5009/api/v2/allocations/notifications/2");
            atomLink1
            .Rel
            .Should().Be("prev-archive");

            var atomLink2 = atomLinksForFeed.ElementAt(1);

            atomLink2
            .Href
            .Should().Be("https://localhost:5009/api/v2/allocations/notifications/4");
            atomLink2
            .Rel
            .Should().Be("next-archive");

            var atomLink3 = atomLinksForFeed.ElementAt(2);

            atomLink3
            .Href
            .Should().Be("https://localhost:5009/api/v2/allocations/notifications/3");
            atomLink3
            .Rel
            .Should().Be("current");

            var atomLink4 = atomLinksForFeed.ElementAt(3);

            atomLink4
            .Href
            .Should().Be("https://localhost:5009/api/v2/allocations/notifications");
            atomLink4
            .Rel
            .Should().Be("self");
        }
        private AtomFeed <AtomEntry> CreateAtomFeedEntry(SearchFeedV3 <PublishedFundingIndex> searchFeed, string fundingUrl)
        {
            AtomFeed <AtomEntry> atomFeed = new AtomFeed <AtomEntry>
            {
                Id     = Guid.NewGuid().ToString("N"),
                Title  = "Calculate Funding Service Funding Feed",
                Author = new CalculateFunding.Models.External.AtomItems.AtomAuthor
                {
                    Name  = "Calculate Funding Service",
                    Email = "*****@*****.**"
                },
                Updated    = DateTimeOffset.Now,
                Rights     = "Copyright (C) 2019 Department for Education",
                Link       = searchFeed.GenerateAtomLinksForResultGivenBaseUrl(fundingUrl).ToList(),
                AtomEntry  = new List <AtomEntry>(),
                IsArchived = searchFeed.IsArchivePage
            };

            return(atomFeed);
        }