public void CrawlerShouldIncludeTemplates()
        {
            // arrange
            using (var db = new Db {
                _source
            })
            {
                var item = db.GetItem("/sitecore/content/source");
                item.Should().NotBeNull();

                var repository = new Mock <IAlgoliaRepository>();
                repository.Setup(t => t.ClearIndexAsync()).ReturnsAsync(JObject.Parse(@"{""taskID"": 722}"));

                var sut = new AlgoliaBaseIndex("test", repository.Object);
                sut.PropertyStore = new NullPropertyStore();
                var configuration = new AlgoliaIndexConfiguration();
                configuration.DocumentOptions = new DocumentBuilderOptions();
                configuration.IncludeTemplate(TestData.TestTemplateId.ToString());

                sut.Configuration = configuration;
                var crawler = new SitecoreItemCrawler();
                crawler.Database = "master";
                crawler.Root     = "/sitecore/content";
                sut.Crawlers.Add(crawler);
                crawler.Initialize(sut);
                sut.Initialize();

                //Act
                sut.Rebuild();

                //Assert
                repository.Verify(t => t.SaveObjectsAsync(It.Is <IEnumerable <JObject> >(o => o.Any())), Times.Once);
            }
        }
        public void CrawlerExludeNotShowInSearchResultsDocuments(string showInSearchResultsFieldName, bool shouldBeCrawled)
        {
            // arrange
            var source = new DbItem("source", TestData.TestItemId, TestData.TestTemplateId)
            {
                { "Show In Search Results", "" }
            };

            using (var db = new Db {
                source
            })
            {
                var item = db.GetItem("/sitecore/content/source");
                item.Should().NotBeNull();

                var repository = new Mock <IAlgoliaRepository>();
                repository.Setup(t => t.ClearIndexAsync()).ReturnsAsync(JObject.Parse(@"{""taskID"": 722}"));

                var sut = new AlgoliaBaseIndex("test", repository.Object);
                sut.PropertyStore = new NullPropertyStore();
                var configuration = new AlgoliaIndexConfiguration
                {
                    DocumentOptions = new DocumentBuilderOptions()
                };

                sut.Configuration = configuration;
                var crawler = new AlgoliaCrawler
                {
                    Database = "master",
                    Root     = "/sitecore/content",
                    ShowInSearchResultsFieldName = showInSearchResultsFieldName,
                };
                sut.Crawlers.Add(crawler);
                crawler.Initialize(sut);
                sut.Initialize();

                //Act
                sut.Rebuild();

                //Assert
                var actual = shouldBeCrawled ? Times.Once() : Times.Never();

                repository.Verify(t => t.SaveObjectsAsync(It.Is <IEnumerable <JObject> >(o => o.Any())), actual);
            }
        }