public void TestInvoice() { var connector = new InvoiceConnector(); connector.Authorization = new StaticTokenAuth(at, cs); var invoice = connector.Get("988"); invoice.PaymentWay = "CASH"; invoice = connector.Update(invoice); Assert.IsFalse(connector.HasError); Assert.IsTrue(invoice.PaymentWay == "CASH"); invoice.PaymentWay = "AA"; invoice = connector.Update(invoice); Assert.IsFalse(connector.HasError); Assert.IsTrue(invoice.PaymentWay == "AA"); }
public void TestInvoice() { var connector = new InvoiceConnector(); connector.AccessToken = at; connector.ClientSecret = cs; var invoice = connector.Get("988"); invoice.PaymentWay = InvoiceConnector.PaymentWay.CASH; invoice = connector.Update(invoice); Assert.IsFalse(connector.HasError); Assert.IsTrue(invoice.PaymentWay == InvoiceConnector.PaymentWay.CASH); invoice.PaymentWay = InvoiceConnector.PaymentWay.AG; invoice = connector.Update(invoice); Assert.IsFalse(connector.HasError); Assert.IsTrue(invoice.PaymentWay == InvoiceConnector.PaymentWay.AG); }
public void Test_Invoice_CRUD() { //Arrange var tmpCustomer = new CustomerConnector().Create(new Customer() { Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", Type = ArticleType.STOCK, PurchasePrice = 100 }); //Act var connector = new InvoiceConnector(); #region CREATE var newInvoice = new Invoice() { CustomerNumber = tmpCustomer.CustomerNumber, InvoiceDate = new DateTime(2019, 1, 20).ToString(APIConstants.DateFormat), //"2019-01-20", DueDate = new DateTime(2019, 2, 20).ToString(APIConstants.DateFormat), //"2019-02-20", InvoiceType = InvoiceType.CASHINVOICE, PaymentWay = "CASH", InvoiceRows = new List <InvoiceRow>() { new InvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10 }, new InvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 20 }, new InvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 15 } } }; var createdInvoice = connector.Create(newInvoice); MyAssert.HasNoError(connector); Assert.AreEqual(createdInvoice.CustomerName, "TmpCustomer"); Assert.AreEqual(3, createdInvoice.InvoiceRows.Count); #endregion CREATE #region UPDATE createdInvoice.City = "UpdatedCity"; var updatedInvoice = connector.Update(createdInvoice); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedCity", updatedInvoice.City); #endregion UPDATE #region READ / GET var retrievedInvoice = connector.Get(createdInvoice.DocumentNumber); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedCity", retrievedInvoice.City); #endregion READ / GET #region DELETE //Invoice does not provide DELETE method, but can be canceled connector.Cancel(createdInvoice.DocumentNumber); MyAssert.HasNoError(connector); retrievedInvoice = connector.Get(createdInvoice.DocumentNumber); Assert.AreEqual(true, retrievedInvoice.Cancelled); #endregion DELETE //Clean new CustomerConnector().Delete(tmpCustomer.CustomerNumber); new ArticleConnector().Delete(tmpArticle.ArticleNumber); }
public void Test_Invoice_CRUD() { #region Arrange var tmpCustomer = new CustomerConnector().Create(new Customer() { Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 100 }); #endregion Arrange IInvoiceConnector connector = new InvoiceConnector(); #region CREATE var newInvoice = new Invoice() { CustomerNumber = tmpCustomer.CustomerNumber, InvoiceDate = new DateTime(2019, 1, 20), //"2019-01-20", DueDate = new DateTime(2019, 2, 20), //"2019-02-20", InvoiceType = InvoiceType.CashInvoice, PaymentWay = PaymentWay.Cash, Comments = "TestInvoice", InvoiceRows = new List <InvoiceRow>() { new InvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10, Price = 100 }, new InvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 20, Price = 100 }, new InvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 15, Price = 100 } } }; var createdInvoice = connector.Create(newInvoice); Assert.AreEqual("TestInvoice", createdInvoice.Comments); Assert.AreEqual("TmpCustomer", createdInvoice.CustomerName); Assert.AreEqual(3, createdInvoice.InvoiceRows.Count); #endregion CREATE #region UPDATE createdInvoice.Comments = "UpdatedInvoice"; var updatedInvoice = connector.Update(createdInvoice); Assert.AreEqual("UpdatedInvoice", updatedInvoice.Comments); #endregion UPDATE #region READ / GET var retrievedInvoice = connector.Get(createdInvoice.DocumentNumber); Assert.AreEqual("UpdatedInvoice", retrievedInvoice.Comments); #endregion READ / GET #region DELETE //Not available, Cancel instead connector.Cancel(createdInvoice.DocumentNumber); var cancelledInvoice = connector.Get(createdInvoice.DocumentNumber); Assert.AreEqual(true, cancelledInvoice.Cancelled); #endregion DELETE #region Delete arranged resources new CustomerConnector().Delete(tmpCustomer.CustomerNumber); //new ArticleConnector().Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }