public void Test_Book() { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); #endregion Arrange ISupplierInvoiceConnector connector = new SupplierInvoiceConnector(); var newSupplierInvoice = new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2020, 1, 1), DueDate = new DateTime(2020, 2, 1), SalesType = SalesType.Stock, OCR = "123456789", Total = 5000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 } } }; var createdSupplierInvoice = connector.Create(newSupplierInvoice); //Act connector.Bookkeep(createdSupplierInvoice.GivenNumber); var bookedInvoice = connector.Get(createdSupplierInvoice.GivenNumber); //Assert Assert.AreEqual(true, bookedInvoice.Booked); Assert.AreEqual(1, bookedInvoice.Vouchers.Count); Assert.AreEqual(ReferenceType.SupplierInvoice, bookedInvoice.Vouchers.First().ReferenceType); #region Delete arranged resources //Can not cancel booked invoice /* connector.Cancel(createdSupplierInvoice.GivenNumber); * new SupplierConnector().Delete(tmpSupplier.SupplierNumber); * new ArticleConnector().Delete(tmpArticle.ArticleNumber);*/ #endregion Delete arranged resources }
public void VatType_Supported() { var vatTypes = Enum.GetValues(typeof(SupplierVATType)).Cast <SupplierVATType>().ToList(); ISupplierConnector connector = new SupplierConnector(); var newSupplier = new Supplier() { Name = "TestSupplier" }; var supplier = connector.Create(newSupplier); MyAssert.HasNoError(connector); foreach (var vat in vatTypes) { supplier.VATType = vat; supplier = connector.Update(supplier); MyAssert.HasNoError(connector); Assert.AreEqual(vat, supplier.VATType); } connector.Delete(supplier.SupplierNumber); }
public void Test_Issue96_fixed() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/96 { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); #endregion Arrange var connector = new SupplierInvoiceConnector(); var createdInvoice = connector.Create(new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2010, 1, 1), DueDate = new DateTime(2010, 2, 1), SalesType = SalesType.Stock, OCR = "123456789", Total = 5000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 } } }); MyAssert.HasNoError(connector); Assert.AreEqual(false, createdInvoice.Cancelled); var retrievedInvoice = connector.Get(createdInvoice.GivenNumber); MyAssert.HasNoError(connector); Assert.AreEqual(false, retrievedInvoice.Cancelled); connector.LastModified = DateTime.Today; var invoiceSubsets = connector.Find().Entities; MyAssert.HasNoError(connector); foreach (var supplierInvoiceSubset in invoiceSubsets) { Assert.IsNotNull(supplierInvoiceSubset.Cancelled); } #region Delete arranged resources new CustomerConnector().Delete(tmpSupplier.SupplierNumber); new ArticleConnector().Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }
public void Test_Find() { #region Arrange //Add code to create required resources #endregion Arrange var testKeyMark = TestUtils.RandomString(); ISupplierConnector connector = new SupplierConnector(); var newSupplier = new Supplier() { Name = "TestSupplier", Address1 = "TestStreet 1", Address2 = "TestStreet 2", ZipCode = "01010", City = testKeyMark, CountryCode = "SE", //CountryCode needs to be valid Email = "*****@*****.**", Active = false, Bank = "TestBank", Currency = "SEK", Phone1 = "01011111345", }; //Add entries for (var i = 0; i < 5; i++) { connector.Create(newSupplier); } //Apply base test filter connector.Search.City = testKeyMark; var fullCollection = connector.Find(); MyAssert.HasNoError(connector); Assert.AreEqual(5, fullCollection.TotalResources); Assert.AreEqual(5, fullCollection.Entities.Count); Assert.AreEqual(1, fullCollection.TotalPages); Assert.AreEqual(testKeyMark, fullCollection.Entities.First().City); //Apply Limit connector.Search.Limit = 2; var limitedCollection = connector.Find(); MyAssert.HasNoError(connector); Assert.AreEqual(5, limitedCollection.TotalResources); Assert.AreEqual(2, limitedCollection.Entities.Count); Assert.AreEqual(3, limitedCollection.TotalPages); //Delete entries foreach (var entry in fullCollection.Entities) { connector.Delete(entry.SupplierNumber); } #region Delete arranged resources //Add code to delete temporary resources #endregion Delete arranged resources }
public void Test_Supplier_CRUD() { var connector = new SupplierConnector(); #region CREATE var newSupplier = new Supplier() { Name = "TestSupplier", Address1 = "TestStreet 1", Address2 = "TestStreet 2", ZipCode = "01010", City = "Testopolis", CountryCode = "SE", //CountryCode needs to be valid Email = "*****@*****.**", Active = false, Bank = "TestBank", Currency = "SEK", Phone1 = "01011111345", }; var createdSupplier = connector.Create(newSupplier); MyAssert.HasNoError(connector); Assert.AreEqual(createdSupplier.Name, "TestSupplier"); #endregion CREATE #region UPDATE createdSupplier.Name = "UpdatedTestSupplier"; var updatedSupplier = connector.Update(createdSupplier); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestSupplier", updatedSupplier.Name); #endregion UPDATE #region READ / GET var retrievedSupplier = connector.Get(createdSupplier.SupplierNumber); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestSupplier", retrievedSupplier.Name); #endregion READ / GET #region DELETE connector.Delete(createdSupplier.SupplierNumber); MyAssert.HasNoError(connector); retrievedSupplier = connector.Get(createdSupplier.SupplierNumber); Assert.AreEqual(null, retrievedSupplier, "Entity still exists after Delete!"); #endregion DELETE }
public void Test_SupplierInvoice_CRUD() { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); #endregion Arrange ISupplierInvoiceConnector connector = new SupplierInvoiceConnector(); #region CREATE var newSupplierInvoice = new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2010, 1, 1), DueDate = new DateTime(2010, 2, 1), SalesType = SalesType.Stock, OCR = "123456789", Total = 5000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 } } }; var createdSupplierInvoice = connector.Create(newSupplierInvoice); Assert.AreEqual("InvoiceComments", createdSupplierInvoice.Comments); Assert.AreEqual("TmpSupplier", createdSupplierInvoice.SupplierName); Assert.AreEqual(3 + 1, createdSupplierInvoice.SupplierInvoiceRows.Count); //3 + 1 => A row "Leverant�rsskulder" is created by default #endregion CREATE #region UPDATE createdSupplierInvoice.Comments = "UpdatedInvoiceComments"; var updatedSupplierInvoice = connector.Update(createdSupplierInvoice); Assert.AreEqual("UpdatedInvoiceComments", updatedSupplierInvoice.Comments); #endregion UPDATE #region READ / GET var retrievedSupplierInvoice = connector.Get(createdSupplierInvoice.GivenNumber); Assert.AreEqual("UpdatedInvoiceComments", retrievedSupplierInvoice.Comments); #endregion READ / GET #region DELETE //Not supported connector.Cancel(createdSupplierInvoice.GivenNumber); var cancelledInvoice = connector.Get(createdSupplierInvoice.GivenNumber); Assert.AreEqual(true, cancelledInvoice.Cancelled); #endregion DELETE #region Delete arranged resources new SupplierConnector().Delete(tmpSupplier.SupplierNumber); new ArticleConnector().Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }
public void Test_Find() { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); #endregion Arrange ISupplierInvoiceConnector connector = new SupplierInvoiceConnector(); var newSupplierInvoice = new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2010, 1, 1), DueDate = new DateTime(2010, 2, 1), SalesType = SalesType.Stock, OCR = "123456789", Total = 5000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 } } }; //Add entries for (var i = 0; i < 5; i++) { connector.Create(newSupplierInvoice); } //Apply base test filter var searchSettings = new SupplierInvoiceSearch(); searchSettings.SupplierNumber = tmpSupplier.SupplierNumber; var fullCollection = connector.Find(searchSettings); Assert.AreEqual(5, fullCollection.TotalResources); Assert.AreEqual(5, fullCollection.Entities.Count); Assert.AreEqual(1, fullCollection.TotalPages); Assert.AreEqual(tmpSupplier.SupplierNumber, fullCollection.Entities.First().SupplierNumber); //Apply Limit searchSettings.Limit = 2; var limitedCollection = connector.Find(searchSettings); Assert.AreEqual(5, limitedCollection.TotalResources); Assert.AreEqual(2, limitedCollection.Entities.Count); Assert.AreEqual(3, limitedCollection.TotalPages); //Delete entries (DELETE not supported) foreach (var invoice in fullCollection.Entities) { connector.Cancel(invoice.GivenNumber); } #region Delete arranged resources new SupplierConnector().Delete(tmpSupplier.SupplierNumber); new ArticleConnector().Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }
public void Test_SupplierInvoicePayment_CRUD() { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); var tmpSpplierInvoice = new SupplierInvoiceConnector().Create(new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2020, 1, 1), DueDate = new DateTime(2020, 2, 1), SalesType = SalesType.Stock, OCR = "123456789", Total = 5000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 } } }); var bookedInvoice = new SupplierInvoiceConnector().Bookkeep(tmpSpplierInvoice.GivenNumber); #endregion Arrange ISupplierInvoicePaymentConnector connector = new SupplierInvoicePaymentConnector(); #region CREATE var newSupplierInvoicePayment = new SupplierInvoicePayment() { InvoiceNumber = (int?)tmpSpplierInvoice.GivenNumber, Amount = 1000, AmountCurrency = 1000, PaymentDate = new DateTime(2020, 1, 20) }; var createdSupplierInvoicePayment = connector.Create(newSupplierInvoicePayment); MyAssert.HasNoError(connector); Assert.AreEqual(1000, createdSupplierInvoicePayment.Amount); #endregion CREATE #region UPDATE createdSupplierInvoicePayment.Amount = 2000; var updatedSupplierInvoicePayment = connector.Update(createdSupplierInvoicePayment); MyAssert.HasNoError(connector); Assert.AreEqual(2000, updatedSupplierInvoicePayment.Amount); #endregion UPDATE #region READ / GET var retrievedSupplierInvoicePayment = connector.Get(createdSupplierInvoicePayment.Number); MyAssert.HasNoError(connector); Assert.AreEqual(2000, retrievedSupplierInvoicePayment.Amount); #endregion READ / GET #region DELETE connector.Delete(createdSupplierInvoicePayment.Number); MyAssert.HasNoError(connector); retrievedSupplierInvoicePayment = connector.Get(createdSupplierInvoicePayment.Number); Assert.AreEqual(null, retrievedSupplierInvoicePayment, "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources new ArticleConnector().Delete(tmpArticle.ArticleNumber); new SupplierConnector().Delete(tmpSupplier.SupplierNumber); #endregion Delete arranged resources }
public void Test_SupplierInvoice_CRUD() { //Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier", CountryCode = "SE", City = "Testopolis" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", Type = ArticleType.STOCK, PurchasePrice = 100 }); //Act var connector = new SupplierInvoiceConnector(); #region CREATE var newInvoice = new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, InvoiceDate = new DateTime(2019, 1, 20).ToString(APIConstants.DateFormat), //"2019-01-20", DueDate = new DateTime(2019, 2, 20).ToString(APIConstants.DateFormat), //"2019-02-20", SalesType = SalesType.STOCK, OCR = "123456789", SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 15 } } }; var createdInvoice = connector.Create(newInvoice); MyAssert.HasNoError(connector); Assert.AreEqual(createdInvoice.SupplierName, "TmpSupplier"); Assert.AreEqual(3 + 1, createdInvoice.SupplierInvoiceRows.Count); //3 + 1 => A row "Leverantörsskulder" is created by default #endregion CREATE #region UPDATE createdInvoice.OCR = "987654321"; var updatedInvoice = connector.Update(createdInvoice); MyAssert.HasNoError(connector); Assert.AreEqual("987654321", updatedInvoice.OCR); #endregion UPDATE #region READ / GET var retrievedInvoice = connector.Get(createdInvoice.GivenNumber); MyAssert.HasNoError(connector); Assert.AreEqual("987654321", retrievedInvoice.OCR); #endregion READ / GET #region DELETE //Invoice does not provide DELETE method, but can be canceled connector.Cancel(createdInvoice.GivenNumber); MyAssert.HasNoError(connector); retrievedInvoice = connector.Get(createdInvoice.GivenNumber); Assert.AreEqual(true, retrievedInvoice.Cancelled); #endregion DELETE //Clean new SupplierConnector().Delete(tmpSupplier.SupplierNumber); new ArticleConnector().Delete(tmpArticle.ArticleNumber); }
public void Test_SupplierInvoiceAccrual_CRUD() { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle" }); var conn = new SupplierInvoiceConnector(); var tmpSupplierInvoice = conn.Create(new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2020, 1, 20), //"2019-01-20", DueDate = new DateTime(2020, 6, 20), //"2019-02-20", SalesType = SalesType.Stock, //OCR = "123456789", Total = 6000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 6, Price = 1000, Account = 5820 } } }); MyAssert.HasNoError(conn); #endregion Arrange ISupplierInvoiceAccrualConnector connector = new SupplierInvoiceAccrualConnector(); #region CREATE var newSupplierInvoiceAccrual = new SupplierInvoiceAccrual() { Description = "TestSupplierInvoiceAccrual", SupplierInvoiceNumber = (int?)tmpSupplierInvoice.GivenNumber, Period = "MONTHLY", AccrualAccount = 1790, CostAccount = 5820, StartDate = new DateTime(2021, 1, 1), EndDate = new DateTime(2021, 3, 1), VATIncluded = false, Total = 2000, SupplierInvoiceAccrualRows = new List <SupplierInvoiceAccrualRow>() { new SupplierInvoiceAccrualRow() { Account = 5820, Credit = 0, Debit = 2000 }, new SupplierInvoiceAccrualRow() { Account = 1790, Credit = 2000, Debit = 0 } } }; var createdSupplierInvoiceAccrual = connector.Create(newSupplierInvoiceAccrual); MyAssert.HasNoError(connector); Assert.AreEqual("TestSupplierInvoiceAccrual", createdSupplierInvoiceAccrual.Description); #endregion CREATE #region UPDATE createdSupplierInvoiceAccrual.Description = "UpdatedTestSupplierInvoiceAccrual"; var updatedSupplierInvoiceAccrual = connector.Update(createdSupplierInvoiceAccrual); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestSupplierInvoiceAccrual", updatedSupplierInvoiceAccrual.Description); #endregion UPDATE #region READ / GET var retrievedSupplierInvoiceAccrual = connector.Get(createdSupplierInvoiceAccrual.SupplierInvoiceNumber); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestSupplierInvoiceAccrual", retrievedSupplierInvoiceAccrual.Description); #endregion READ / GET #region DELETE connector.Delete(createdSupplierInvoiceAccrual.SupplierInvoiceNumber); MyAssert.HasNoError(connector); retrievedSupplierInvoiceAccrual = connector.Get(createdSupplierInvoiceAccrual.SupplierInvoiceNumber); Assert.AreEqual(null, retrievedSupplierInvoiceAccrual, "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources new SupplierConnector().Delete(tmpSupplier.SupplierNumber); new ArticleConnector().Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }
public void Test_SupplierInvoiceExternalURLConnection_CRUD() { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); var tmpSpplierInvoice = new SupplierInvoiceConnector().Create(new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2020, 1, 1), DueDate = new DateTime(2020, 2, 1), SalesType = SalesType.Stock, OCR = "123456789", Total = 5000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 } } }); #endregion Arrange ISupplierInvoiceExternalURLConnectionConnector connector = new SupplierInvoiceExternalURLConnectionConnector(); #region CREATE var newSupplierInvoiceExternalURLConnection = new SupplierInvoiceExternalURLConnection() { SupplierInvoiceNumber = (int?)tmpSpplierInvoice.GivenNumber, ExternalURLConnection = @"http://example.com/image.jpg" }; var createdSupplierInvoiceExternalURLConnection = connector.Create(newSupplierInvoiceExternalURLConnection); MyAssert.HasNoError(connector); Assert.AreEqual("http://example.com/image.jpg", createdSupplierInvoiceExternalURLConnection.ExternalURLConnection); #endregion CREATE #region UPDATE createdSupplierInvoiceExternalURLConnection.ExternalURLConnection = "http://example.com/image.png"; var updatedSupplierInvoiceExternalURLConnection = connector.Update(createdSupplierInvoiceExternalURLConnection); MyAssert.HasNoError(connector); Assert.AreEqual("http://example.com/image.png", updatedSupplierInvoiceExternalURLConnection.ExternalURLConnection); #endregion UPDATE #region READ / GET var retrievedSupplierInvoiceExternalURLConnection = connector.Get(createdSupplierInvoiceExternalURLConnection.Id); MyAssert.HasNoError(connector); Assert.AreEqual("http://example.com/image.png", retrievedSupplierInvoiceExternalURLConnection.ExternalURLConnection); #endregion READ / GET #region DELETE connector.Delete(createdSupplierInvoiceExternalURLConnection.Id); MyAssert.HasNoError(connector); retrievedSupplierInvoiceExternalURLConnection = connector.Get(createdSupplierInvoiceExternalURLConnection.Id); Assert.AreEqual(null, retrievedSupplierInvoiceExternalURLConnection, "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources new ArticleConnector().Delete(tmpArticle.ArticleNumber); new SupplierConnector().Delete(tmpSupplier.SupplierNumber); #endregion Delete arranged resources }
public void Test_Supplier_CRUD() { #region Arrange //Add code to create required resources #endregion Arrange ISupplierConnector connector = new SupplierConnector(); #region CREATE var newSupplier = new Supplier() { Name = "TestSupplier", Address1 = "TestStreet 1", Address2 = "TestStreet 2", ZipCode = "01010", City = "Testopolis", CountryCode = "SE", //CountryCode needs to be valid Email = "*****@*****.**", Active = false, Bank = "TestBank", Currency = "SEK", Phone1 = "01011111345", BG = "1111111", PG = "1111111" }; var createdSupplier = connector.Create(newSupplier); Assert.AreEqual("TestSupplier", createdSupplier.Name); #endregion CREATE #region UPDATE createdSupplier.Name = "UpdatedSupplier"; var updatedSupplier = connector.Update(createdSupplier); Assert.AreEqual("UpdatedSupplier", updatedSupplier.Name); #endregion UPDATE #region READ / GET var retrievedSupplier = connector.Get(createdSupplier.SupplierNumber); Assert.AreEqual("UpdatedSupplier", retrievedSupplier.Name); #endregion READ / GET #region DELETE connector.Delete(createdSupplier.SupplierNumber); Assert.ThrowsException <FortnoxApiException>( () => connector.Get(createdSupplier.SupplierNumber), "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources //Add code to delete temporary resources #endregion Delete arranged resources }
public void Test_SupplierInvoiceFileConnection_CRUD() { #region Arrange var tmpSupplier = new SupplierConnector().Create(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); var tmpSpplierInvoice = new SupplierInvoiceConnector().Create(new SupplierInvoice() { SupplierNumber = tmpSupplier.SupplierNumber, Comments = "InvoiceComments", InvoiceDate = new DateTime(2020, 1, 1), DueDate = new DateTime(2020, 2, 1), SalesType = SalesType.Stock, OCR = "123456789", Total = 5000, SupplierInvoiceRows = new List <SupplierInvoiceRow>() { new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 }, new SupplierInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100 } } }); var tmpFile = new InboxConnector().UploadFile("tmpImage.png", Resource.fortnox_image, StaticFolders.SupplierInvoices); #endregion Arrange ISupplierInvoiceFileConnectionConnector connector = new SupplierInvoiceFileConnectionConnector(); #region CREATE var newSupplierInvoiceFileConnection = new SupplierInvoiceFileConnection() { SupplierInvoiceNumber = tmpSpplierInvoice.GivenNumber.ToString(), FileId = tmpFile.Id }; var createdSupplierInvoiceFileConnection = connector.Create(newSupplierInvoiceFileConnection); MyAssert.HasNoError(connector); Assert.AreEqual(tmpSupplier.Name, createdSupplierInvoiceFileConnection.SupplierName); #endregion CREATE #region UPDATE //Not supported #endregion UPDATE #region READ / GET var retrievedSupplierInvoiceFileConnection = connector.Get(createdSupplierInvoiceFileConnection.FileId); MyAssert.HasNoError(connector); Assert.AreEqual(tmpSupplier.Name, retrievedSupplierInvoiceFileConnection.SupplierName); #endregion READ / GET #region DELETE connector.Delete(createdSupplierInvoiceFileConnection.FileId); MyAssert.HasNoError(connector); retrievedSupplierInvoiceFileConnection = connector.Get(createdSupplierInvoiceFileConnection.FileId); Assert.AreEqual(null, retrievedSupplierInvoiceFileConnection, "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources new ArticleConnector().Delete(tmpArticle.ArticleNumber); new SupplierConnector().Delete(tmpSupplier.SupplierNumber); #endregion Delete arranged resources }