Пример #1
0
        public void GetAll_PointFolderItemPassed_ShouldCallSearchService(Db db, Foundation.Indexing.Repositories.ISearchServiceRepository searchRepo, [Substitute] Foundation.Indexing.SearchService service)
        {
            var itemid = ID.NewID;

            db.Add(new DbItem("point", itemid, Templates.MapPointsFolder.ID));
            searchRepo.Get().Returns(service);
            var repository = new MapPointRepository(searchRepo);

            repository.GetAll(db.GetItem(itemid));
            service.FindAll().Received(1);
        }
Пример #2
0
        public void GetAll_PointFolderItemPassed_ShouldReturnsItemsFromSearchService([Content] Data.Items.Item[] items, Db db, Foundation.Indexing.Repositories.ISearchServiceRepository searchRepo, [Substitute] Foundation.Indexing.SearchService service, Foundation.Indexing.Models.ISearchResults results, Foundation.Indexing.Models.ISearchResult result)
        {
            var itemid = ID.NewID;

            db.Add(new DbItem("point", itemid, Templates.MapPointsFolder.ID));
            searchRepo.Get().Returns(service);
            service.FindAll().Returns(results);
            var searchResutls = items.Select(x =>
            {
                var sr = Substitute.For <Foundation.Indexing.Models.ISearchResult>();
                sr.Item.Returns(x);
                return(sr);
            });

            results.Results.Returns(searchResutls);

            var repository = new MapPointRepository(searchRepo);
            var actual     = repository.GetAll(db.GetItem(itemid));

            actual.Count().Should().Be(items.Length);
        }