using Centron.BusinessLogic.Sales.Receipts.DataAndResults; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Data.WebServices.Sales.Receipts.Offers; using Centron.Interfaces; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket139506; public class Ticket139506Tests : EndToEndTest { public Ticket139506Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int CustomerI3D = 10009; public const int ActiveContractI3D = 8; public const int DeactivatedContractI3D = 4; public override void Execute() { // In this ticket the problem was, that when you had 2 default-contracts (Rahmenvertrag) // One of them was active, the other was deactivated // It would choose the deactivated one by accident, and then show nothing in the UI this.PrepareDatabase(); var offer = this.CreateNewOffer(); Assert.Equal(ActiveContractI3D, offer.ContractI3D); } private void PrepareDatabase() { this.Sql($"UPDATE dbo.VertragKopf SET Rahmenvertrag = 1, Status = 1 WHERE I3D = {ActiveContractI3D}"); this.Sql($"UPDATE dbo.VertragKopf SET Rahmenvertrag = 1, Status = 0 WHERE I3D = {DeactivatedContractI3D}"); } private ReceiptOfferDTO CreateNewOffer() { var result = this.WithSession(s => s.GetBL().CreateNewReceipt( CentronObjectKindNumeric.OfferClass, this.GetLoggedInUser(), CustomerI3D, new CreateReceiptData { IgnoreCallbacks = true, }, addressI3D: null, contactPersonI3D: null, insertSalutationAndAgreement: false, ignoreDefaultContract: false, insertCustomerDiscount: false)).ThrowIfError().Receipt; return (ReceiptOfferDTO)result; } }