using System; using System.Linq; using Centron.BusinessLogic.Administration.Masterdata; using Centron.BusinessLogic.Sales.Receipts; using Centron.BusinessLogic.Sales.Receipts.Internal; using Centron.DAO; using Centron.Data.Entities.Sales.Receipts.Invoices; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket111051 { public class Ticket11051Test : EndToEndTest { public Ticket11051Test(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { this.PrepareDatabase(); this.CreateConditionText("Mandat1", mandatI3D: 1); this.CreateConditionText("Mandat2", mandatI3D: 2); } private void CreateConditionText(string name, int mandatI3D) { using (var session = new DAOSession()) { session.StartTransaction(); try { // Load receipt, mandats and condition-text var receipt = new ReceiptBL(session).GetReceiptByI3D(4396); var allMandats = new ReceiptBL(session).GetReceiptMandats(receipt.CustomerI3D); var text = new AssetConditionBL(session).GetAssetConditionText(receipt.PaymentConditionI3D.Value, receipt.CountryI3D.GetValueOrDefault(0)); text.Text = "@PI @PBN @PBB @PM"; // Update condition-text to include the mandat-variables var mandat = allMandats.FirstOrDefault(f => f.I3D == mandatI3D); if (mandat == null) throw new Exception($"The mandat with I3D {mandatI3D} was not found."); // Change the mandat on the receipt receipt.MandatI3D = mandat.I3D; // Get the replaced text var replacedText = new AssetConditionTextReplacementBL(session).ReplaceAssetConditionText(text, receipt); this.Verifier.Verify(name, replacedText); } finally { // Rollback everything at the end so we don't save anything to the database session.RollbackTransaction(); } } } private void PrepareDatabase() { this.Sql(@"INSERT INTO dbo.Bankverbindungen (Status, BankName, IBAN, ObjectI3D, ObjectArt, BIC, AuthorizationNumber) VALUES(1, 'Test-Bank', 'DE0123456789', 10000, 0, 'CETESTBIC', '123456')"); } } }