Esempio n. 1
0
        public void GetFeeeds_GivenInvalidPageRef_ThrowsArgumentException()
        {
            //Arrange
            int pageRef = 0;

            AllocationNotificationsFeedsSearchService searchService = CreateSearchService();

            //Act
            Func <Task> test = async() => await searchService.GetFeeds(pageRef);

            //Assert
            test
            .Should()
            .ThrowExactly <ArgumentException>();
        }
Esempio n. 2
0
        public async Task GetFeedsV2_GivenResultsFound_ReturnsFeed()
        {
            //Arrange
            int pageRef = 1;

            int top = 0;

            SearchResults <AllocationNotificationFeedIndex> searchResults = new SearchResults <AllocationNotificationFeedIndex>
            {
                TotalCount = 2,
                Results    = new List <CalculateFunding.Repositories.Common.Search.SearchResult <AllocationNotificationFeedIndex> >
                {
                    new CalculateFunding.Repositories.Common.Search.SearchResult <AllocationNotificationFeedIndex>
                    {
                        Result = new AllocationNotificationFeedIndex()
                    },
                    new CalculateFunding.Repositories.Common.Search.SearchResult <AllocationNotificationFeedIndex>
                    {
                        Result = new AllocationNotificationFeedIndex()
                    }
                }
            };

            ISearchRepository <AllocationNotificationFeedIndex> searchRepository = CreateSearchRepository();

            searchRepository
            .Search(Arg.Is(""), Arg.Any <SearchParameters>())
            .Returns(searchResults);


            AllocationNotificationsFeedsSearchService searchService = CreateSearchService(searchRepository);

            //Act
            SearchFeed <AllocationNotificationFeedIndex> searchFeed = await searchService.GetFeeds(pageRef, top);

            //Assert
            searchFeed.Should().NotBeNull();
            searchFeed.Id.Should().NotBeEmpty();
            searchFeed.PageRef.Should().Be(1);
            searchFeed.Top.Should().Be(500);
            searchFeed.TotalCount.Should().Be(2);
            searchFeed.TotalPages.Should().Be(1);
            searchFeed.Self.Should().Be(1);
            searchFeed.Last.Should().Be(1);
            searchFeed.Next.Should().Be(1);
            searchFeed.Previous.Should().Be(1);
            searchFeed.Entries.Count().Should().Be(2);
        }
Esempio n. 3
0
        public async Task GetFeeds_GivenNoStatuses_SearchesWithNoFilter()
        {
            //Arrange
            int pageRef = 1;

            int top = 0;

            ISearchRepository <AllocationNotificationFeedIndex> searchRepository = CreateSearchRepository();

            AllocationNotificationsFeedsSearchService searchService = CreateSearchService(searchRepository);

            //Act
            SearchFeed <AllocationNotificationFeedIndex> searchFeed = await searchService.GetFeeds(pageRef, top);

            //Assert
            await
            searchRepository
            .Received(1)
            .Search(Arg.Is(""), Arg.Is <SearchParameters>(m => m.Filter == ""));
        }
Esempio n. 4
0
        public async Task GetFeeds_GivenInvalidTopPassed_DefaultsTopTo500()
        {
            //Arrange
            int pageRef = 1;

            int top = 0;

            ISearchRepository <AllocationNotificationFeedIndex> searchRepository = CreateSearchRepository();

            AllocationNotificationsFeedsSearchService searchService = CreateSearchService(searchRepository);

            //Act
            SearchFeed <AllocationNotificationFeedIndex> searchFeed = await searchService.GetFeeds(pageRef, top);

            //Assert
            await
            searchRepository
            .Received(1)
            .Search(Arg.Is(""), Arg.Is <SearchParameters>(m => m.Top == 500 && m.OrderBy.First() == "dateUpdated desc"));
        }
Esempio n. 5
0
        public async Task GetFeeds_GivenPublishedStatus_SearchesWithFilter()
        {
            //Arrange
            int pageRef = 1;

            int top = 0;

            IEnumerable <string> statuses = new[] { "Published" };

            ISearchRepository <AllocationNotificationFeedIndex> searchRepository = CreateSearchRepository();

            AllocationNotificationsFeedsSearchService searchService = CreateSearchService(searchRepository);

            //Act
            SearchFeed <AllocationNotificationFeedIndex> searchFeed = await searchService.GetFeeds(pageRef, top, statuses);

            //Assert
            await
            searchRepository
            .Received(1)
            .Search(Arg.Is(""), Arg.Is <SearchParameters>(m => m.Filter == "allocationStatus eq 'Published'"));
        }