Ejemplo n.º 1
0
        public void ShouldReturnInventoryItemsForScopedSearch()
        {
            var itemInfo = _searchHelper.CreatSaleInventoryItem();

            Thread.Sleep(5000);

            var searchProxy = new SearchProxy();
            var result1     = searchProxy.Search(itemInfo.ItemDetail.Description, SearchScope.InventoryItems, 1, 25);

            Assert.NotNull(result1);
            Assert.NotNull(result1.DataObject);
            Assert.True(result1.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.True(result1.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0.");
            Assert.True(result1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts");
            Assert.True(result1.DataObject.TotalContactsFound == 0, "Should not return contacts for search scoped to Contacts");
            Assert.Contains(result1.DataObject.InventoryItems, i => i.Id == itemInfo.ItemId);

            var result2 = searchProxy.Search(itemInfo.ItemDetail.Code, SearchScope.InventoryItems, 1, 25);

            Assert.NotNull(result2);
            Assert.NotNull(result2.DataObject);
            Assert.True(result2.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.True(result2.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0.");
            Assert.Contains(result2.DataObject.InventoryItems, i => i.Id == itemInfo.ItemId);

            var result3 = searchProxy.Search(itemInfo.ItemDetail.Code, SearchScope.InventoryItems, 1, 25);

            Assert.NotNull(result3);
            Assert.NotNull(result3.DataObject);
            Assert.True(result3.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.True(result3.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0.");
            Assert.Contains(result3.DataObject.InventoryItems, i => i.Id == itemInfo.ItemId);
        }
Ejemplo n.º 2
0
        public void ShouldReturnContactsForScopedSearch()
        {
            var createdContactInfo = _searchHelper.CreateContact();

            Thread.Sleep(5000); // Need to wait for entities to be indexed

            var searchProxy = new SearchProxy();
            var results1    = searchProxy.Search($"{createdContactInfo.ContactDetail.GivenName} {createdContactInfo.ContactDetail.FamilyName}", SearchScope.Contacts, 1, 25);

            Assert.NotNull(results1);
            Assert.True(results1.DataObject.Contacts.Count > 0, "No contacts returned.");
            Assert.True(results1.DataObject.TotalContactsFound > 0, "transaction count is 0.");
            Assert.True(results1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts");
            Assert.True(results1.DataObject.TotalInventoryItemsFound == 0, "Should not return items for search scoped to Contacts");
            Assert.Contains(results1.DataObject.Contacts, c => c.Id == createdContactInfo.ContactId);


            var results2 = searchProxy.Search(createdContactInfo.ContactDetail.EmailAddress, SearchScope.Contacts, 1, 25);

            Assert.NotNull(results2);
            Assert.True(results2.DataObject.Contacts.Count > 0, "No contacts returned.");
            Assert.True(results2.DataObject.TotalContactsFound > 0, "transaction count is 0.");
            Assert.Contains(results2.DataObject.Contacts, c => c.Id == createdContactInfo.ContactId);

            var companyProxy    = new CompanyProxy();
            var companyResponse = companyProxy.GetCompany(createdContactInfo.ContactDetail.CompanyId.Value);

            var results3 = searchProxy.Search(companyResponse.DataObject.Name, SearchScope.Contacts, 1, 25);

            Assert.NotNull(results3);
            Assert.True(results3.DataObject.Contacts.Count > 0, "No contacts returned.");
            Assert.True(results3.DataObject.TotalContactsFound > 0, "transaction count is 0.");
            Assert.Contains(results3.DataObject.Contacts, c => c.Id == createdContactInfo.ContactId);
        }
Ejemplo n.º 3
0
        public void IndexedContactShouldMatchEntityData()
        {
            var contactInfo = _searchHelper.CreateContact();

            Thread.Sleep(5000); // Need to wait for entities to be indexed

            var searchProxy = new SearchProxy();

            var contact = new ContactProxy().GetContact(contactInfo.ContactId).DataObject;

            var searchResults = searchProxy.Search(contact.EmailAddress, SearchScope.Contacts, 1, 10);

            Assert.NotNull(searchResults.DataObject);
            Assert.True(searchResults.DataObject.Contacts.Count > 0);

            var indexedContact = searchResults.DataObject.Contacts.First(x => ReplaceEm(x.ContactEmail) == contact.EmailAddress);

            Assert.NotNull(indexedContact);
            Assert.Equal(contact.GivenName + " " + contact.FamilyName, ReplaceEm(indexedContact.Name));
            Assert.Equal(contact.MobilePhone, indexedContact.MobilePhone);
            Assert.Equal(contact.PrimaryPhone, indexedContact.MainPhone);
            Assert.Equal(contact.Id, indexedContact.Id);
            Assert.Equal("Contact", indexedContact.EntityType);
            Assert.Equal(contact.CompanyId ?? 0, indexedContact.CompanyId);
            Assert.Equal(contact.TwitterId, indexedContact.TwitterId);
        }
Ejemplo n.º 4
0
        public void ShouldReturnContactsTransactionsInventoryItemsForMatchAll()
        {
            var faker         = _searchHelper.GetSaleInvoiceFaker();
            var invoiceDetail = faker.Generate();
            var response      = new InvoiceProxy().InsertInvoice(invoiceDetail);

            Assert.True(response != null && response.IsSuccessfull);

            _searchHelper.CreatSaleInventoryItem(invoiceDetail.Summary);
            _searchHelper.CreateContact(companyName: invoiceDetail.Summary);
            Thread.Sleep(5000); // Need to wait for entities to be indexed


            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search("*:*", SearchScope.All, 1, 25);

            Assert.NotNull(results);
            Assert.NotNull(results.DataObject);
            Assert.True(results.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.True(results.DataObject.Contacts.Count > 0, "No contacts returned.");
            Assert.True(results.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.True(results.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0.");
            Assert.True(results.DataObject.TotalContactsFound > 0, "transaction count is 0.");
            Assert.True(results.DataObject.TotalTransactionsFound > 0, "transaction count is 0.");
        }
Ejemplo n.º 5
0
        public void IndexedContactShouldMatchEntityData()
        {
            var searchProxy   = new SearchProxy();
            var contactHelper = new ContactHelper();

            var contactResponse = contactHelper.AddContact();

            Thread.Sleep(2000);
            var contact = new ContactProxy().GetContact(contactResponse.InsertedContactId).DataObject;

            var searchResults = searchProxy.Search(contact.EmailAddress, SearchScope.Contacts, 1, 10);

            Assert.IsNotNull(searchResults.DataObject);
            Assert.IsTrue(searchResults.DataObject.Contacts.Count > 0);

            var indexedContact = searchResults.DataObject.Contacts.First(x => ReplaceEm(x.ContactEmail) == contact.EmailAddress);

            Assert.IsNotNull(indexedContact);
            Assert.AreEqual(contact.GivenName + " " + contact.FamilyName, ReplaceEm(indexedContact.Name));
            Assert.AreEqual(contact.MobilePhone, indexedContact.MobilePhone);
            Assert.AreEqual(contact.PrimaryPhone, indexedContact.MainPhone);
            Assert.AreEqual(contact.Id, indexedContact.Id);
            Assert.AreEqual("Contact", indexedContact.EntityType);
            Assert.AreEqual(contact.CompanyId ?? 0, indexedContact.CompanyId);
            Assert.AreEqual(contact.TwitterId, indexedContact.TwitterId);
        }
Ejemplo n.º 6
0
        public void IndexedInventoryItemShouldMatchEntityData()
        {
            var searchProxy = new SearchProxy();

            var itemInfo = _searchHelper.CreatSaleInventoryItem();

            Thread.Sleep(5000);

            var searchResults = searchProxy.Search(itemInfo.ItemDetail.Code, SearchScope.InventoryItems, 1, 10);

            Assert.NotNull(searchResults.DataObject);
            Assert.True(searchResults.DataObject.InventoryItems.Count > 0);

            var indexedInventoryItem = searchResults.DataObject.InventoryItems.First(x => ReplaceEm(x.Code) == itemInfo.ItemDetail.Code);

            Assert.NotNull(indexedInventoryItem);
            Assert.Equal(itemInfo.ItemDetail.BuyingPrice, indexedInventoryItem.BuyingPrice);
            Assert.Equal(itemInfo.ItemDetail.Description, ReplaceEm(indexedInventoryItem.Description));
            Assert.Equal(itemInfo.ItemDetail.Type, indexedInventoryItem.Type);
            Assert.Equal("Item", indexedInventoryItem.EntityType);
            Assert.Equal(itemInfo.ItemId, indexedInventoryItem.Id);
            Assert.Equal(itemInfo.ItemDetail.SellingPrice, indexedInventoryItem.SellingPrice);
            Assert.Equal(itemInfo.ItemDetail.StockOnHand.HasValue ? itemInfo.ItemDetail.StockOnHand : 0M, indexedInventoryItem.StockOnHand);
            Assert.Equal(itemInfo.ItemDetail.PrimarySupplierItemCode, indexedInventoryItem.SupplierItemCode);
        }
Ejemplo n.º 7
0
        public void ShouldReturnPurchasesOnlyWhenTransactionEntityTypeSpecified()
        {
            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search("test", SearchScope.Transactions, 1, 25, "transactions.purchase");

            Assert.IsNotNull(results, "No search results returned.");
            Assert.IsNotNull(results.DataObject, "No search result object returned.");
            Assert.IsTrue(results.DataObject.Transactions.TrueForAll(x => x.Type == "P"));
        }
Ejemplo n.º 8
0
        public void ShouldReturnContactsForScopedSearch()
        {
            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search("test", SearchScope.Contacts, 1, 25);

            Assert.IsNotNull(results, "No search results returned.");
            Assert.IsTrue(results.DataObject.Contacts.Count > 0, "No contacts returned.");
            Assert.IsTrue(results.DataObject.TotalContactsFound > 0, "transaction count is 0.");
            Assert.IsTrue(results.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts");
            Assert.IsTrue(results.DataObject.TotalInventoryItemsFound == 0, "Should not return items for search scoped to Contacts");
        }
Ejemplo n.º 9
0
        public void ShouldReturnNotResults()
        {
            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search("zzzzzzzzzzzzzzzzzzzzzz", SearchScope.All, 1, 25);

            Assert.NotNull(results);
            Assert.NotNull(results.DataObject);
            Assert.Equal(0, results.DataObject.InventoryItems.Count);
            Assert.Equal(0, results.DataObject.Contacts.Count);
            Assert.Equal(0, results.DataObject.InventoryItems.Count);
            Assert.Equal(0, results.DataObject.TotalInventoryItemsFound);
            Assert.Equal(0, results.DataObject.TotalContactsFound);
            Assert.Equal(0, results.DataObject.TotalTransactionsFound);
        }
Ejemplo n.º 10
0
        public void ShouldReturnNotResults()
        {
            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search("qwerty", SearchScope.All, 1, 25);

            Assert.IsNotNull(results, "No search results returned.");
            Assert.IsNotNull(results.DataObject, "No search result object returned.");
            Assert.AreEqual(0, results.DataObject.InventoryItems.Count);
            Assert.AreEqual(0, results.DataObject.Contacts.Count);
            Assert.AreEqual(0, results.DataObject.InventoryItems.Count);
            Assert.AreEqual(0, results.DataObject.TotalInventoryItemsFound);
            Assert.AreEqual(0, results.DataObject.TotalContactsFound);
            Assert.AreEqual(0, results.DataObject.TotalTransactionsFound);
        }
Ejemplo n.º 11
0
        public void ShouldReturnContactsTransactionsInventoryItemsForScopedAllSearch()
        {
            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search("test", SearchScope.All, 1, 25);

            Assert.IsNotNull(results, "No search results returned.");
            Assert.IsNotNull(results.DataObject, "No search result object returned.");
            Assert.IsTrue(results.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.IsTrue(results.DataObject.Contacts.Count > 0, "No contacts returned.");
            Assert.IsTrue(results.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.IsTrue(results.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0.");
            Assert.IsTrue(results.DataObject.TotalContactsFound > 0, "transaction count is 0.");
            Assert.IsTrue(results.DataObject.TotalTransactionsFound > 0, "transaction count is 0.");
        }
Ejemplo n.º 12
0
        public void ShouldReturnContactsMatchAllSearch()
        {
            var createdContactInfo = _searchHelper.CreateContact();

            Thread.Sleep(5000); // Need to wait for entities to be indexed

            var searchProxy = new SearchProxy();
            var results1    = searchProxy.Search("*:*", SearchScope.Contacts, 1, 25);

            Assert.NotNull(results1);
            Assert.True(results1.DataObject.Contacts.Count > 0, "No contacts returned.");
            Assert.True(results1.DataObject.TotalContactsFound > 0, "transaction count is 0.");
            Assert.True(results1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts");
            Assert.True(results1.DataObject.TotalInventoryItemsFound == 0, "Should not return items for search scoped to Contacts");
        }
Ejemplo n.º 13
0
        public void ShouldReturnInventoryItemsForMatchAllSearch()
        {
            var itemInfo = _searchHelper.CreatSaleInventoryItem();

            Thread.Sleep(5000);

            var searchProxy = new SearchProxy();
            var result1     = searchProxy.Search("*:*", SearchScope.InventoryItems, 1, 25);

            Assert.NotNull(result1);
            Assert.NotNull(result1.DataObject);
            Assert.True(result1.DataObject.InventoryItems.Count > 0, "No inventory items returned.");
            Assert.True(result1.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0.");
            Assert.True(result1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts");
            Assert.True(result1.DataObject.TotalContactsFound == 0, "Should not return contacts for search scoped to Contacts");
        }
Ejemplo n.º 14
0
        public void ShouldReturnSaleTransactionForScopedSearchByInvoiceNumber()
        {
            var searchProxy   = new SearchProxy();
            var faker         = _searchHelper.GetSaleInvoiceFaker();
            var invoiceDetail = faker.Generate();
            var response      = new InvoiceProxy().InsertInvoice(invoiceDetail);

            Assert.True(response != null && response.IsSuccessfull);
            Thread.Sleep(5000); // Need to wait for entities to be indexed

            var results1 = searchProxy.Search(response.DataObject.GeneratedInvoiceNumber, SearchScope.Transactions, 1, 25);

            Assert.NotNull(results1);
            Assert.True(results1.DataObject.Transactions.Count > 0, "No transactions returned.");
            Assert.True(results1.DataObject.TotalTransactionsFound > 0, "transaction count is 0.");
            Assert.Equal(0, results1.DataObject.TotalContactsFound);
            Assert.Equal(0, results1.DataObject.TotalInventoryItemsFound);
            Assert.Contains(results1.DataObject.Transactions, t => t.Id == response.DataObject.InsertedEntityId);
        }
Ejemplo n.º 15
0
        public void ShouldReturnPurchasesOnlyWhenTransactionEntityTypeSpecified()
        {
            var invoiceProxy = new InvoiceProxy();
            var saleInfo     = _searchHelper.GetSaleInvoiceFaker().Generate();
            var saleResponse = invoiceProxy.InsertInvoice(saleInfo);

            Assert.True(saleResponse != null && saleResponse.IsSuccessfull);

            var purchaseInfo     = _searchHelper.GetPurchaseInvoiceFaker(saleInfo.Summary).Generate();
            var purchaseResponse = invoiceProxy.InsertInvoice(purchaseInfo);

            Assert.True(purchaseResponse != null && purchaseResponse.IsSuccessfull);
            Thread.Sleep(5000); // Need to wait for entities to be indexed


            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search(purchaseInfo.Summary, SearchScope.Transactions, 1, 25, "transactions.purchase");

            Assert.NotNull(results);
            Assert.NotNull(results.DataObject);
            Assert.True(results.DataObject.Transactions.TrueForAll(x => x.Type == "P"));
        }
Ejemplo n.º 16
0
        public void IndexedTransactionShouldMatchEntityData()
        {
            var searchProxy = new SearchProxy();
            var invoice     = new InvoiceProxy().GetInvoice(_invoiceHelper.InvoiceId1.Value).DataObject;

            Assert.IsNotNull(invoice.BillingContactId, "Contact not found");
            var contact = new ContactProxy().GetContact(invoice.BillingContactId.Value).DataObject;

            var searchResults = searchProxy.Search(_invoiceHelper.InvoiceId1Summary, SearchScope.Transactions, 1, 100);

            Assert.IsNotNull(searchResults.DataObject);
            Assert.IsTrue(searchResults.DataObject.Transactions.Count > 0);
            var indexedTransaction = searchResults.DataObject.Transactions.First(x => x.Id == invoice.TransactionId);

            Assert.AreEqual(invoice.DueDate, indexedTransaction.DueDate);
            Assert.AreEqual(invoice.BillingContactOrganisationName, indexedTransaction.Company);
            Assert.AreEqual(contact.EmailAddress, ReplaceEm(indexedTransaction.ContactEmail));
            Assert.AreEqual(invoice.InvoiceNumber, indexedTransaction.InvoiceNumber);
            Assert.AreEqual(invoice.PurchaseOrderNumber, indexedTransaction.PurchaseOrderNumber);
            Assert.AreEqual(invoice.NotesExternal, indexedTransaction.ExternalNotes);
            Assert.AreEqual(invoice.NotesInternal, indexedTransaction.Notes);
            Assert.AreEqual(invoice.TransactionType, indexedTransaction.Type);
        }
Ejemplo n.º 17
0
        public void IndexedInventoryItemShouldMatchEntityData()
        {
            var searchProxy = new SearchProxy();

            var inventoryItem = InsertAndGetInventoryItem();

            var searchResults = searchProxy.Search(inventoryItem.Code, SearchScope.InventoryItems, 1, 10);

            Assert.IsNotNull(searchResults.DataObject);
            Assert.IsTrue(searchResults.DataObject.InventoryItems.Count > 0);

            var indexedInventoryItem = searchResults.DataObject.InventoryItems.First(x => ReplaceEm(x.Code) == inventoryItem.Code);

            Assert.IsNotNull(indexedInventoryItem);
            Assert.AreEqual(inventoryItem.BuyingPrice, indexedInventoryItem.BuyingPrice);
            Assert.AreEqual(inventoryItem.Description, ReplaceEm(indexedInventoryItem.Description));
            Assert.AreEqual(inventoryItem.Type, indexedInventoryItem.Type);
            Assert.AreEqual("Item", indexedInventoryItem.EntityType);
            Assert.AreEqual(inventoryItem.Id, indexedInventoryItem.Id);
            Assert.AreEqual(inventoryItem.SellingPrice, indexedInventoryItem.SellingPrice);
            Assert.AreEqual(inventoryItem.StockOnHand.HasValue ? inventoryItem.StockOnHand : 0M, indexedInventoryItem.StockOnHand);
            Assert.AreEqual(inventoryItem.PrimarySupplierItemCode, indexedInventoryItem.SupplierItemCode);
        }