public void PagingResults() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); //// Get enumerator //var count = client.For<Account>().Count(); //var result = client.For<Account>() // .Expand("BankAccounts") // .Skip(10) // .Get(); //Assert.IsTrue(result.Count == (count - 10)); var accounts = client.For <Account>() .Select("ID,Code,Name") .Where("Name+eq+'Test Eurobike'") .Get(); string hoi = ""; foreach (var account in accounts) { hoi += account.Name + "\t" + account.Code + "\n"; } }
public void UpdateReadonlyFields_IgnoresReadonlyFields() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var account = client.For <Account>().Top(1).Select("ID,Name").Get().First(); var originalName = account.Name; var originalId = account.ID; account.Name = "Test account name2"; account.Created = DateTime.Now; account.Creator = new Guid("c20a5590-c605-4f59-8fbb-112ee142bc59"); account.CreatorFullName = "Edward Jackson"; account.ID = originalId; account.LogoThumbnailUrl = "www.google.nl"; account.Modified = DateTime.Now; account.Modifier = new Guid("c20a5590-c605-4f59-8fbb-112ee142bc59"); account.ModifierFullName = "Test"; account.ClassificationDescription = "Test"; account.CostcenterDescription = "Test"; account.InvoiceAccountCode = "Test"; account.InvoiceAccountName = "Test"; account.LanguageDescription = "Bla"; account.PurchaseCurrencyDescription = "Test"; account.ResellerCode = "Test"; account.ResellerName = "Test"; account.SalesCurrencyDescription = "Test"; account.SalesVATCodeDescription = "Test"; account.StateName = "Test"; Assert.IsTrue(client.For <Account>().Update(account)); // Change it back to testname account.Name = originalName; Assert.IsTrue(client.For <Account>().Update(account)); }
public void UpdateLinkedEntities() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var salesInvoiceId = CreateSalesInvoice(client, 1); // Fetch sales invoice including sales invoice lines var salesInvoice = client.For <SalesInvoice>() .Select("InvoiceID,SalesInvoiceLines/ID,SalesInvoiceLines/InvoiceID,SalesInvoiceLines/Description") .Expand("SalesInvoiceLines") .GetEntity(salesInvoiceId); var salesInvoiceLines = (List <SalesInvoiceLine>)salesInvoice.SalesInvoiceLines; var orginialInvoiceline = salesInvoiceLines[0]; // The original invoice line is not managed because it's taken as related entity from the sales invoice. // Call the api to get a managed invoice line that can be updated. var managedInvoiceLine = client.For <SalesInvoiceLine>().GetEntity(orginialInvoiceline.ID); managedInvoiceLine.Description = string.Format("Changed On {0}", DateTime.UtcNow); // Update and compare client.For <SalesInvoiceLine>().Update(managedInvoiceLine); Assert.AreNotEqual(orginialInvoiceline.Description, managedInvoiceLine.Description); }
public void ExactOnlineQuery_WithWrongProperty_Fails() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); client.For <Account>().Select(new[] { "Xxx" }).Get(); }
public void CreateUserDocument() { var testObject = new TestObjectsCreator(); var client = new ExactOnlineClient(testObject.EndPoint, testObject.GetOAuthAuthenticationToken); var created = CreateDocument(client); Assert.IsTrue(created); }
public void GetSpecificCollectionUsingOData_WithNonExistingEntity() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var accounts = client.For <Object>() .Where("Description+eq+'Gebouwen'") .Get(); }
public void GetCollectionOfAllAcountEntitiesInCSharpObjects_Succeeds() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var accounts = client.For <Account>().Select("ID").Get(); Assert.IsTrue(accounts.Count > 0, "Get Collection Of All Account Entities in CSharp Objects is not implemented corectly"); }
public void GetUserDocument() { var testObject = new TestObjectsCreator(); var client = new ExactOnlineClient(testObject.EndPoint, testObject.GetOAuthAuthenticationToken); var document = GetDocument(client); Assert.IsNotNull(document); Assert.AreEqual(document.ID, _documentId); }
public void ExpiredAccessToken_Succeeds() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); System.Threading.Thread.Sleep(600000); //Sleep for 10 minutes, then the token is expired var accounts = client.For <Account>().Select("ID").Get(); Assert.IsTrue(accounts.Count > 0); }
public void ExactOnlineQuery_WithCorrectProperty_Succeeds() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var accounts = client.For <Account>() .Select(new[] { "Code" }) .Get(); Assert.IsTrue(accounts.Count > 1); }
public void DeleteUserDocument() { var testObject = new TestObjectsCreator(); var client = new ExactOnlineClient(testObject.EndPoint, testObject.GetOAuthAuthenticationToken); var document = GetDocument(client); var result = client.For <Document>().Delete(document); Assert.IsTrue(result); // Document does not exist anymore so it throws an exception client.For <Document>().GetEntity(document.ID); }
// Tests if the API returns '"d"' and 'results' tags. If not, the controllers will not work correctly public void Test_ResponseHasCorrectTags_Succeeds() { var toc = new TestObjectsCreator(); var conn = toc.ApiConnector(); var currentDivision = toc.GetCurrentDivision(); var response = conn.DoGetRequest(toc.UriGlAccount(currentDivision), string.Empty); if (!response.Contains("\"d\"") || !response.Contains("\"results\"")) { throw new Exception("Response does not have correct tags (\"d\" or \"results\")."); } }
public void GetSpecificCollectionUsingOData() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var accounts = client.For <GLAccount>() .Select("Code") .Where("Description+eq+'Gebouwen'") .And("Code+eq+'0300'") .Get(); Assert.IsTrue(accounts.Any()); }
public void GetCollectionOfAccountsInJsonFormat_Succeeds() { var toc = new TestObjectsCreator(); var conn = new ApiConnection(toc.ApiConnector(), toc.UriCrmAccount(toc.GetCurrentDivision())); var c = new SimpleController(conn); List <dynamic> accounts = c.GetDynamic(string.Empty); // Test if list has entities (easy test, because actual entity count isn't known) if (accounts.Count < 1) { throw new Exception("User Story not correctly implemented: List of CRM/Accounts is empty"); } }
public void GetSpecificCollectionUsingOData_WithOutOData() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var accounts = client.For <GLAccount>() .Select("Code") .Get(); if (!accounts.Any()) { throw new Exception("The collection of Account entities is empty"); } }
public void GetSpecificCollectionUsingOData_WithNonExistingField() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var accounts = client.For <Account>() .Select("Code") .Where("Description+eq+'Gebouwen'") .Get(); if (accounts.Count > 1) { throw new Exception("The collection has entities, but filter field does not exist. Exception expected."); } }
public void UpdateUserDocument() { var testObject = new TestObjectsCreator(); var client = new ExactOnlineClient(testObject.EndPoint, testObject.GetOAuthAuthenticationToken); var document = GetDocument(client); const string subject = "User Acceptance Test Document Updated"; // Update document document.Subject = subject; document.DocumentDate = DateTime.Now.Date; var updated = client.For <Document>().Update(document); var updatedDocument = client.For <Document>().GetEntity(document.ID); Assert.IsTrue(updated); Assert.IsNotNull(updatedDocument); Assert.AreEqual(subject, updatedDocument.Subject); }
public void DeleteLinkedEntities() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); // Create a sales invoice with 2 lines var salesInvoiceId = CreateSalesInvoice(client, 2); // Get one of the invoice lines var filter = string.Format("InvoiceID+eq+guid'{0}'", salesInvoiceId); var invoiceLine = client.For <SalesInvoiceLine>().Select("ID").Where(filter).Get().First(); // Delete the line var deleted = client.For <SalesInvoiceLine>().Delete(invoiceLine); Assert.IsTrue(deleted); }
public void AccessLinkedEntities_Succeeds() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var salesinvoices = client.For <SalesInvoice>() .Select("InvoiceID,SalesInvoiceLines/ID") .Expand("SalesInvoiceLines") .Top(1) .Get(); Assert.IsNotNull(salesinvoices); var salesinvoicelines = (List <SalesInvoiceLine>)salesinvoices.First().SalesInvoiceLines; Assert.IsTrue(salesinvoicelines.Count > 0); }
public void GetApiResponseAfterGetCall_Succeeds() { //APIConnector connector = new APIConnector(accesstoken); var toc = new TestObjectsCreator(); var conn = new ApiConnection(toc.ApiConnector(), toc.UriCrmAccount(toc.GetCurrentDivision())); string result = conn.Get(string.Empty); if (result == string.Empty) { throw new Exception("Return from API was empty"); } else { // Check if the response is a JSON Value // Throws exception of not JSON JsonConvert.DeserializeObject(result); } }
public void ModificationRestrictions_Succeed() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); // Create var newJournal = new Journal { Description = "New Journal" }; try { client.For <Journal>().Insert(ref newJournal); throw new Exception(); } catch { } // Update Journal journal = client.For <Journal>().Top(1).Select("ID").Get().First(); journal.Description = "Test Description"; try { client.For <Journal>().Update(journal); throw new Exception(); } catch { } // Delete try { client.For <Journal>().Delete(journal); throw new Exception(); } catch { } }
public void CreateSalesInvoiceWithLine() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var customerId = GetCustomerId(client); var itemId = GetItemId(client); var newInvoice = new SalesInvoice { Currency = "EUR", OrderDate = new DateTime(2012, 10, 26), InvoiceTo = customerId, Journal = "70", OrderedBy = customerId, Description = "New invoice for Entity With Collection" }; var newInvoiceLine = new SalesInvoiceLine { Description = "New invoice line for Entity With Collection", Item = itemId }; var invoicelines = new List <SalesInvoiceLine> { newInvoiceLine }; newInvoice.SalesInvoiceLines = invoicelines; // Add SalesInvoice to Database Assert.IsTrue(client.For <SalesInvoice>().Insert(ref newInvoice)); // Get SalesInvoice and check if contains collections of InvoiceLines SalesInvoice salesInvoice = client.For <SalesInvoice>() .Expand("SalesInvoiceLines") .GetEntity(newInvoice.InvoiceID.ToString()); Assert.IsNotNull(salesInvoice); Assert.AreEqual(1, salesInvoice.SalesInvoiceLines.Count()); }
public void CreateLinkedEntities() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); // Fetch sales invoice var salesInvoiceId = CreateSalesInvoice(client, 1); var salesinvoice = client.For <SalesInvoice>().GetEntity(salesInvoiceId); // Fetch item var item = client.For <Item>().Top(1).Select("ID").Where("IsSalesItem+eq+true").Get().First(); // add line var invoiceline = new SalesInvoiceLine { Description = "New Sales Invoice Line", InvoiceID = salesinvoice.InvoiceID, Item = item.ID }; Assert.IsTrue(client.For <SalesInvoiceLine>().Insert(ref invoiceline)); }
public void DeleteAccountWithDeleteMethod() { var toc = new TestObjectsCreator(); // Create new account var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); var newAccount = new Account { Name = "Test account" }; if (client.For <Account>().Insert(ref newAccount)) { // Try to delete account if (!client.For <Account>().Delete(newAccount)) { throw new Exception("Failed to delete test account entity. Possibly this test will not work as the database is now corrupt. Please delete account with name 'Account for 184249' manualy"); } } else { throw new Exception("Cannot create test account entity"); } }
public void AlterStateAccountObjectDirectly_Succeeds() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); // Get account to update var accounts = client.For <Account>().Top(1).Select("ID").Get(); var account = accounts.First(); // Change name of account & update account.Name = "Test Name UAT2"; if (!client.For <Account>().Update(account)) { throw new Exception("Account is not updated"); } else { // Change account back for test purposes account.Name = "Test Name UAT"; if (!client.For <Account>().Update(account)) { throw new Exception("Changing account entity back for tests failed. Possibly these tests won't work anymore"); } } }
private static int GetCurrentDivision(TestObjectsCreator toc) { var clientWithoutDivision = new ExactOnlineClient(toc.GetWebsite(), toc.GetOAuthAuthenticationToken); return(clientWithoutDivision.GetDivision()); }
public void Setup() { _toc = new TestObjectsCreator(); _currentDivision = _toc.GetCurrentDivision(); }
public void Setup() { var toc = new TestObjectsCreator(); _conn = new ApiConnection(toc.ApiConnector(), toc.UriGlAccount(toc.GetCurrentDivision())); }
public void ExactClient_TestEndPointWithoutSlash_Succeeds() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(string.Format("{0}", toc.GetWebsite()), toc.GetOAuthAuthenticationToken); }
public void ReadAllEntities() { var toc = new TestObjectsCreator(); var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken); // Not supported entities //var printedSalesInvoiceCollection = client.For<PrintedSalesInvoice>().Get(); // Does only support post //var salesItemPriceCollection = client.For<SalesItemPrice>().Get(); // Is a function //var stockPositionCollection = client.For<StockPosition>().Get(); // Is a function // Read Entities var agingOverviewCollection = client.For <AgingOverview>().Select("AmountPayable").Get(); var accountCollection = client.For <Account>().Select("ID").Get(); var accountClassCollection = client.For <AccountClass>().Select("ID").Get(); var assetCollection = client.For <Asset>().Select("ID").Get(); var bankAccountCollection = client.For <BankAccount>().Select("ID").Get(); var budgetCollection = client.For <Budget>().Select("ID").Get(); var contactCollection = client.For <Contact>().Select("ID").Get(); var costcenterCollection = client.For <Costcenter>().Select("ID").Get(); var costTransactionCollection = client.For <CostTransaction>().Select("ID").Get(); var costunitCollection = client.For <Costunit>().Select("ID").Get(); var divisionCollection = client.For <Division>().Select("HID").Get(); var documentCollection = client.For <Document>().Select("ID").Get(); var documentAttachmentCollection = client.For <DocumentAttachment>().Select("ID").Get(); var documentCategoryCollection = client.For <DocumentCategory>().Select("ID").Get(); var documentTypeCollection = client.For <DocumentType>().Select("ID").Get(); var documentTypeCategoryCollection = client.For <DocumentTypeCategory>().Select("ID").Get(); var employeeCollection = client.For <Employee>().Select("ID").Get(); var exchangeRateCollection = client.For <ExchangeRate>().Select("ID").Get(); var financialPeriodCollection = client.For <FinancialPeriod>().Select("ID").Get(); var glAccountCollection = client.For <GLAccount>().Select("ID").Get(); var glClassificationCollection = client.For <GLClassification>().Select("ID").Get(); var glSchemeCollection = client.For <GLScheme>().Select("ID").Get(); var itemCollection = client.For <Item>().Select("ID").Get(); var itemGroupCollection = client.For <ItemGroup>().Select("ID").Get(); var journalCollection = client.For <Journal>().Select("ID").Get(); var layoutCollection = client.For <Layout>().Select("ID").Get(); var mailboxCollection = client.For <Mailbox>().Select("ID").Get(); var mailMessageCollection = client.For <MailMessage>().Select("ID").Get(); var mailMessageAttachmentCollection = client.For <MailMessageAttachment>().Select("ID").Get(); var operationCollection = client.For <Operation>().Select("ID").Get(); var operationResourceCollection = client.For <OperationResource>().Select("ID").Get(); var opportunityCollection = client.For <Opportunity>().Select("ID").Get(); var opportunityContactCollection = client.For <OpportunityContact>().Select("ID").Get(); var outstandingInvoiceOverviewCollection = client.For <OutstandingInvoiceOverview>().Select("CurrencyCode").Get(); var paymentConditionCollection = client.For <PaymentCondition>().Select("ID").Get(); //var periodRevenueCollection = client.For<PeriodRevenue>().Select("Year,Period").Get(); compound key not supported var priceListCollection = client.For <PriceList>().Select("ID").Get(); var productionAreaCollection = client.For <ProductionArea>().Select("ID").Get(); var salesEntryCollection = client.For <SalesEntry>().Select("EntryID").Get(); var salesEntryLineCollection = client.For <SalesEntryLine>().Select("ID").Get(); var salesInvoiceCollection = client.For <SalesInvoice>().Select("InvoiceID").Get(); var salesInvoiceLineCollection = client.For <SalesInvoiceLine>().Select("ID").Get(); var shopOrderCollection = client.For <ShopOrder>().Select("ID").Get(); var shopOrderMaterialPlanCollection = client.For <ShopOrderMaterialPlan>().Select("ID").Get(); var shopOrderRoutingStepPlanCollection = client.For <ShopOrderRoutingStepPlan>().Select("ID").Get(); var taxDocumentCollection = client.For <TaxDocument>().Select("DocumentID").Get(); var timeTransactionCollection = client.For <TimeTransaction>().Select("ID").Get(); var unitCollection = client.For <Unit>().Select("ID").Get(); var userCollection = client.For <User>().Select("UserID").Get(); var userRoleCollection = client.For <UserRole>().Select("ID").Get(); var vatCodeCollection = client.For <VATCode>().Select("Code").Get(); var warehouseCollection = client.For <Warehouse>().Select("ID").Get(); var workcenterCollection = client.For <Workcenter>().Select("ID").Get(); }