using Centron.BusinessLogic; using Centron.BusinessLogic.WebServices.Accounts; using Centron.BusinessLogic.WebServices.Accounts.SpecialPrices; using Centron.Interfaces.Accounts; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.AccountArticleSpecialPrices.CopyToChildCompanyGroups; public class CopyToChildCompanyGroupTests : EndToEndTest { public CopyToChildCompanyGroupTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { this.Verifier.Settings.IgnoreColumn("Erstelldatum"); } private const int ParentAccountI3D = 19; private const int ParentCustomerNumber = 10020; private const int ChildAccountI3D = 1025; private const int ChildCustomerNumber = 10026; public override void Execute() { this.PrepareDatabase(); this.CopySpecialPrices(); } private void PrepareDatabase() { var filter = new AccountFilter() { AccountI3D = ChildAccountI3D }; var account = this.WithSession(f => f.GetBL().GetAccount(this.GetLoggedInUser(), filter, mixMode: false)).ThrowIfError(); account.CompanyGroupI3D = ParentAccountI3D; this.WithSession(f => f.GetBL().SaveAccount(this.GetLoggedInUser(), account, mixMode: false, isDataImport: false)).ThrowIfError(); } private void CopySpecialPrices() { using var session = new BLSession(); var copyResult = session.GetBL().CopyAccountSpecialPricesToCompanyGroupChilds(ParentCustomerNumber, this.GetLoggedInUser()); this.Verifier.Verify("CopyResult", copyResult); this.Verifier.VerifySql("ParentSpecialPrices", $"SELECT * FROM KundenSonderpreise WHERE KundenI3D = {ParentCustomerNumber}"); this.Verifier.VerifySql("ChildSpecialPrices", $"SELECT * FROM KundenSonderpreise WHERE KundenI3D = {ChildCustomerNumber}"); } }