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
        public void CustomerEntityFramework()
        {
            // Register Repository (Override existing regristation)
            Sample.Azure.DI.Container.RegisterType <Sample.Azure.Interface.Repository.ICustomerRepository, Sample.Azure.Repository.SqlServer.Customer.CustomerRepository>();

            Model.Customer.CustomerModel customerModel = this.CreateCustomerModel();

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

            Model.Customer.CustomerModel loadedModel = customerService.Get(customerModel.CustomerId);
            Assert.AreEqual(loadedModel.CustomerName, customerModel.CustomerName);
        } // CustomerEntityFramework