public void Can_create_azuresearch_index()
 {
     var scope = "test";
     var queryBuilder = new AzureSearchQueryBuilder();
     var conn = new SearchConnection(Datasource, scope, accessKey: AccessKey);
     var provider = new AzureSearchProvider(queryBuilder, conn);           
     SearchHelper.CreateSampleIndex(provider, scope);
     provider.RemoveAll(scope, String.Empty);
 }
        public void Can_find_item_azuresearch()
        {
            var scope = "test";
            var queryBuilder = new AzureSearchQueryBuilder();
            var conn = new SearchConnection(Datasource, scope, accessKey: AccessKey);
            var provider = new AzureSearchProvider(queryBuilder, conn);

            provider.RemoveAll(scope, String.Empty);
            SearchHelper.CreateSampleIndex(provider, scope);

            var criteria = new CatalogItemSearchCriteria
            {
                SearchPhrase = "product",
                IsFuzzySearch = true,
                Catalog = "goods",
                RecordsToRetrieve = 10,
                StartingRecord = 0,
                Pricelists = new string[] { }
            };


            // force delay, otherwise records are not available
            Thread.Sleep(1000); 

            var results = provider.Search(scope, criteria);
            
            Assert.True(results.DocCount == 1, String.Format("Returns {0} instead of 1", results.DocCount));

            criteria = new CatalogItemSearchCriteria
            {
                SearchPhrase = "sample product ",
                IsFuzzySearch = true,
                Catalog = "goods",
                RecordsToRetrieve = 10,
                StartingRecord = 0,
                Pricelists = new string[] { }
            };


            results = provider.Search(scope, criteria);

            Assert.True(results.DocCount == 1, String.Format("\"Sample Product\" search returns {0} instead of 1", results.DocCount));

            provider.RemoveAll(scope, String.Empty);
        }