Ejemplo n.º 1
0
        public void CustomerAzureSearch()
        {
            Model.Customer.CustomerModel customerModel = this.CreateCustomerModel();

            Interface.Service.ICustomerService customerService = DI.Container.Resolve <Interface.Service.ICustomerService>();
            customerService.Save(customerModel);

            Model.Search.SearchCustomerModel searchCustomerModel = new Model.Search.SearchCustomerModel();
            searchCustomerModel.CustomerId   = customerModel.CustomerId.ToString().ToLower();
            searchCustomerModel.CustomerName = customerModel.CustomerName;

            Interface.Repository.IIndexerRepository azureSearch = DI.Container.Resolve <Interface.Repository.IIndexerRepository>();

            azureSearch.UpsertCustomer(Interface.GlobalEnum.IndexerIndexName.Customer, searchCustomerModel);

            List <Model.Search.SearchCustomerModel> list = azureSearch.CustomerSearch(Interface.GlobalEnum.IndexerIndexName.Customer, customerModel.CustomerName);

            bool found = false;

            foreach (var item in list)
            {
                if (item.CustomerName == customerModel.CustomerName)
                {
                    Assert.AreEqual(list[0].CustomerName, customerModel.CustomerName);
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                Assert.Fail("Could not find customer in Azure Search");
            }
        } // CustomerAzureSearch
Ejemplo n.º 2
0
        private void searchRead_Click(object sender, EventArgs e)
        {
            int loop = Int32.Parse(txtLoop.Text);

            Interface.Repository.IIndexerRepository azureSearch = DI.Container.Resolve <Interface.Repository.IIndexerRepository>();

            Model.Search.SearchLargeObjectModel searchLargeObjectModel = new Model.Search.SearchLargeObjectModel();
            searchLargeObjectModel.LargeObjectId = largeObjectModel.LargeObjectId.ToString();
            searchLargeObjectModel.Payload       = largeObjectModel.Payload;

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            for (int i = 1; i <= loop; i++)
            {
                azureSearch.LargeObjectSearch(Interface.GlobalEnum.IndexerIndexName.LargeObject, i.ToString());
            }
            stopwatch.Stop();

            txtResult.Text  = string.Empty;
            txtResult.Text += "Read Write (" + loop.ToString() + ") took: " + stopwatch.ElapsedMilliseconds.ToString() + " milliseconds." + Environment.NewLine;
            txtResult.Text += "Read Write (" + loop.ToString() + ") took: " + (stopwatch.ElapsedMilliseconds / 1000).ToString() + " seconds." + Environment.NewLine;
        }
Ejemplo n.º 3
0
        public void LargeObjectAzureSearch()
        {
            Model.LargeObject.LargeObjectModel largeObjectModel = this.CreateLargeObjectModel();
            largeObjectModel.LargeObjectId = 1;

            // This would save to blob or somewhere
            //Interface.Service.ILargeObjectService largeObjectService = DI.Container.Resolve<Interface.Service.ILargeObjectService>();
            //largeObjectService.Save(largeObjectModel);

            Model.Search.SearchLargeObjectModel searchLargeObjectModel = new Model.Search.SearchLargeObjectModel();
            searchLargeObjectModel.LargeObjectId = largeObjectModel.LargeObjectId.ToString();
            searchLargeObjectModel.Payload       = largeObjectModel.Payload;

            Interface.Repository.IIndexerRepository azureSearch = DI.Container.Resolve <Interface.Repository.IIndexerRepository>();

            azureSearch.UpsertLargeObject(Interface.GlobalEnum.IndexerIndexName.LargeObject, searchLargeObjectModel);

            List <Model.Search.SearchLargeObjectModel> list = azureSearch.LargeObjectSearch(
                Interface.GlobalEnum.IndexerIndexName.LargeObject, largeObjectModel.LargeObjectId.ToString());

            Assert.AreEqual(list[0].LargeObjectId, largeObjectModel.LargeObjectId.ToString());
        } // LargeObjectAzureSearch