public void GetAll_NullPassed_ShouldThrowArgumentNullException([Frozen] Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
        {
            var    repository = new MapPointRepository(searchServiceRepository);
            Action a          = () => repository.GetAll(null);

            a.ShouldThrow <ArgumentNullException>();
        }
        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);
        }
        public void GetAll_PointItemPassed_ShouldReturnSinglePoint(Db db, [Frozen] Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
        {
            var itemid = ID.NewID;

            db.Add(new DbItem("point", itemid, Templates.MapPoint.ID)
            {
                { Templates.MapPoint.Fields.MapPointName, "nameField" }
            });
            var repository = new MapPointRepository(searchServiceRepository);
            var actual     = repository.GetAll(db.GetItem(itemid));

            actual.Single().Name.Should().Be("nameField");
        }
        public void GetAll_WrongItemPassed_ShouldThrowException([FakeDb.AutoFixture.Content] Data.Items.Item item, [Frozen] Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
        {
            var    repository = new MapPointRepository(searchServiceRepository);
            Action a          = () => repository.GetAll(item);

            a.ShouldThrow <ArgumentException>();
        }
 public MapPointRepository(Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
 {
     this.searchServiceRepository = searchServiceRepository;
 }
Example #6
0
 public MapPointRepository(Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
 {
   this.searchServiceRepository = searchServiceRepository;
 }
        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);
        }