using Centron.BusinessLogic; using Centron.BusinessLogic.EmployeeArea; using Centron.BusinessLogic.Warehousing; using Centron.BusinessLogic.WebServices.Warehousing; using Centron.Data.Entities.Administration.Logins; using Centron.Data.WebServices.Warehousing; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket126856; public class TicketTest126856Test : EndToEndTest { public TicketTest126856Test(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { this.LoadAndSaveAnArticle(); } private int ArticleI3D = 52; private const int APPUSERI3D = 11; private void LoadAndSaveAnArticle() { var user = WithSession(f => f.GetBL().GetAppUser(f => f.I3D == APPUSERI3D)); var article1 = WithSession(f => f.GetBL().GetArticleByArticleI3D(ArticleI3D)); // change this property to ensure we run into the problematic code article1.ScanBarcode = !article1.ScanBarcode; // Should fail, because there is stock available for the article. In this case it is forbidden to change the ScanBarcode property var result1 = WithSession(f => f.GetBL().SaveArticle(article1, new LoggedInUser(user))); this.Verifier.Verify("LoadAndSavedArticle_failed", result1); // set all barcodes to 'booked out manually' so that the stock check is bypassed base.Sql("UPDATE Barcode SET Status = 20 WHERE ArtikelI3D = 52 AND Status IN (1,2, 8)"); base.Sql("UPDATE ARTIK SET Menge = 0 WHERE I3D = 52"); //sometimes the changes tracker does not work right and bring the 'article has been changed by somebody else'-message, even if it's not the case //so we save here to see, if this is happening now result1 = WithSession(f => f.GetBL().SaveArticle(article1, new LoggedInUser(user))); this.Verifier.Verify("LoadAndSavedArticle", result1); var article2 = WithSession(f => f.GetBL().GetArticleByArticleI3D(ArticleI3D)); article2.ScanBarcode = !article2.ScanBarcode; //sometime volume prices are not saved article2.VolumePrices.Add(new ArticleVolumePricesDTO() { State = 0, EK = (decimal)12.34, FromAmount = 2, VK1 = (decimal)56.78, ArticleI3D = article2.I3D }); article2.VolumePrices.Add(new ArticleVolumePricesDTO() { State = 1, EK = (decimal)120.34, FromAmount = 42, VK1 = (decimal)560.78, ArticleI3D = article2.I3D }); var result2 = WithSession(f =>f.GetBL().SaveArticle(article2, new LoggedInUser(user))); this.Verifier.Verify("LoadAndSavedArticle_The_Second", result2); var article3 = WithSession(f => f.GetBL().GetArticleByArticleI3D(ArticleI3D)); article3.ScanBarcode = !article3.ScanBarcode; //just check the first case again, because it does not always occur var result3 = WithSession(f => f.GetBL().SaveArticle(article3, new LoggedInUser(user))); this.Verifier.Verify("LoadAndSavedArticle_Third_times_a_charm", result3); // and because Easter is just around the corner, here is a bad pun // What kind of jewelry does the easter bunny wear ? // 24 carrot gold } }