using Centron.BusinessLogic; using Centron.BusinessLogic.WebServices.Administration.Company; using Centron.BusinessLogic.WebServices.Administration.MasterData; using Centron.Data.WebServices.Administration.MandatoryArea; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.BranchArea; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.NumberGroupTests.Ticket125719 { public class Ticket125719 : EndToEndTest { // the problem that we had was, when we create a new mandant and a new branch to it // the number groups for that branch would be created, but never shown in the UI // the reason for it was taht we were trying to get the branch number groups where // current value was != null and != 0, which was of course not the case since // the new number groups are created with value null for current and the list would be empty // test workflow: // 1. create new mandant // 2. create new branch for mandant // 3. create number groups for the new branch // 4. get number groups for the new branch public Ticket125719(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { var mandantI3D = this.CreateNewMandant(); var branchI3D = this.CreateNewBranchForNewMandant(mandantI3D); this.GetNumberGroupsForNewBranch(mandantI3D, branchI3D); } private int CreateNewMandant() { using (var session = new BLSession()) { var newMandant = new MandatoryExtendedDTO { Mandator = "Ticket 125719", State = 1 }; var mandant = session.GetBL().SaveMandatoryExtended(newMandant).ThrowIfError(); return mandant.I3D; } } private int CreateNewBranchForNewMandant(int mandantI3D) { using (var session = new BLSession()) { var country = session.GetBL().GetDefaultCountry(); var federalState = session.GetBL().GetFederalStates().FirstOrDefault(); var newBranch = new BranchDTO { Name = "Branch for Ticket 125719", MandatorI3D = mandantI3D, CountryI3D = country.I3D, FederalState = federalState, CreatedDate = DateTime.Now, IsDefault = 0, Status = 1, }; var branch = session.GetBL().SaveBranchDetails(newBranch).ThrowIfError(); return branch.I3D; } } private void GetNumberGroupsForNewBranch(int mandantI3D, int branchI3D) { using (var session = new BLSession()) { session.GetBL().CreateNumberGroups(mandantI3D, branchI3D).ThrowIfError(); var numberGroups = session.GetBL().GetNumberGroupsForBranch(mandantI3D, branchI3D).ThrowIfError(); this.Verifier.Verify($"GetNumberGroupsForBranch", numberGroups); } } } }