예제 #1
0
        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";
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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 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");
        }
예제 #5
0
        public void CreateUserDocument()
        {
            var testObject = new TestObjectsCreator();
            var client = new ExactOnlineClient(testObject.EndPoint, testObject.GetOAuthAuthenticationToken);

            var created = CreateDocument(client);
            Assert.IsTrue(created);
        }
예제 #6
0
        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();
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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\").");
            }
        }
예제 #12
0
        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()
        {
            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");
            }
        }
예제 #15
0
        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.");
            }
        }
예제 #16
0
        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);
        }
예제 #17
0
        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 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 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");
            }
        }
예제 #20
0
        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));
        }
예제 #21
0
        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 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");
                }
            }
        }
예제 #23
0
 public void ExactClient_GetCurrentMe_Succeeds()
 {
     var toc = new TestObjectsCreator();
     var client = new ExactOnlineClient(toc.EndPoint, toc.GetOAuthAuthenticationToken);
     Assert.IsNotNull(client.CurrentMe());
 }
 public void Setup()
 {
     var toc = new TestObjectsCreator();
     _conn = new ApiConnection(toc.ApiConnector(), toc.UriGlAccount(toc.GetCurrentDivision()));
 }
예제 #25
0
 public void InitializeSharedTestObjects()
 {
     _toc = new TestObjectsCreator();
     _currentDivision = GetCurrentDivision(_toc);
 }
예제 #26
0
 private static int GetCurrentDivision(TestObjectsCreator toc)
 {
     var clientWithoutDivision = new ExactOnlineClient(toc.GetWebsite(), toc.GetOAuthAuthenticationToken);
     return clientWithoutDivision.GetDivision();
 }
예제 #27
0
 public void ExactClient_TestEndPointWithSlash_Succeeds()
 {
     var toc = new TestObjectsCreator();
     var client = new ExactOnlineClient(toc.GetWebsite(), toc.GetOAuthAuthenticationToken);
 }
예제 #28
0
 public void Setup()
 {
     _toc = new TestObjectsCreator();
     _currentDivision = _toc.GetCurrentDivision();
 }