using System.Collections.Generic; using System.Linq; using Centron.BusinessLogic.Mail.Factory; using Centron.BusinessLogic.WebServices.Administration.MasterData; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.BusinessLogic.WebServices.Sales.Support; using Centron.Data.WebServices.Administration.Employees; using Centron.Data.WebServices.EmployeeArea; using Centron.Interfaces; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket135987; public class Ticket135987Tests : EndToEndTest { public Ticket135987Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int OrderI3D = 120; public const int NewEditorI3D = 28; public override void Execute() { // 1. Create a ticket from an order // 2. Change the editor in that ticket // 3. Make some changes in the order again, to see the "create ticket from order" dialog again // // The problem now is, that the dialog shows the wrong editor // It shows the original one again (usually the one, who's service article was used to created the ticket) // But it should show the current ticket editor using (TestMails.Start(out var mails)) { // 1. Create a ticket from the order var createdTickets = this.WithSession(s => s.GetBL().CreateHelpdesksForReceipt(CentronObjectKindNumeric.OrderClass, OrderI3D, null, this.GetLoggedInUser().User)).ThrowIfError(); // 2. Change the editor in that ticket var helpdeskI3D = createdTickets.First().HelpdeskI3D; this.ChangeHelpdeskEditor(helpdeskI3D); // 3. Call the "create ticket from order" method again var ticketInfos = this.WithSession(s => s.GetBL().GetHelpdeskInfosForReceipt(CentronObjectKindNumeric.OrderClass, OrderI3D, this.GetLoggedInUser().User)).ThrowIfError(); // Should be the new editor I3D now Assert.Equal(NewEditorI3D, ticketInfos.Single.First().EmployeeI3D); // For good measure, also use the Verifier to check all properties this.Verifier.Verify("TicketInfos", ticketInfos); } } private void ChangeHelpdeskEditor(int helpdeskI3D) { var helpdesk = this.WithSession(s => s.GetBL().GetHelpdeskByI3D(helpdeskI3D, this.GetLoggedInUser())).ThrowIfError(); var employees = this.WithSession(s => s.GetBL().GetEmployeePreviews(new List { NewEditorI3D })).ThrowIfError(); helpdesk.Editors = employees.ToList(); this.WithSession(s => s.GetBL().SaveHelpdesk(helpdesk, this.GetLoggedInUser())).ThrowIfError(); } }