using System; using Centron.BusinessLogic; using Centron.BusinessLogic.Accounts; using Centron.Interfaces.Accounts; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Accounts; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Account { public class AccountRelationshipTests : EndToEndTest { // Example Partners private const int MicrosoftAccountI3D = 1036; private const int MicrosoftAccountContactI3D = 1061; private const int HPAccountI3D = 1034; private const int HPAccountContactI3D = 1059; // Example Accounts private const int CentronAccountI3D = 1; private const int CentronAccountContactI3D = 4; private const int MuellerAccountI3D = 10; private const int StadtvTuttlAccountI3D = 16; private const int CelosSoftAccountI3D = 1028; public AccountRelationshipTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { using (var session = new BLSession()) { CreateRelationships(session); UpdateRelationshipSettings(session); ValidateRelationships(session, 1); RemoveRelationship(session); ValidateRelationships(session, 2); CreateDublicateRelationship(session); SearchSpecificRelationships(session); } } private void CreateRelationships(BLSession session) { var bl = session.GetBL(); // Add some accounts to Microsoft GmbH bl.AddPartnerTooAccount(CentronAccountI3D, MicrosoftAccountI3D, MicrosoftAccountContactI3D); bl.AddPartnerTooAccount(MuellerAccountI3D, MicrosoftAccountI3D, MicrosoftAccountContactI3D); bl.AddPartnerTooAccount(StadtvTuttlAccountI3D, MicrosoftAccountI3D, MicrosoftAccountContactI3D); bl.AddPartnerTooAccount(CelosSoftAccountI3D, MicrosoftAccountI3D, MicrosoftAccountContactI3D); bl.AddPartnerTooAccount(HPAccountI3D, MicrosoftAccountI3D, MicrosoftAccountContactI3D); // Add some accounts to Hewlett Packard bl.AddPartnerTooAccount(MuellerAccountI3D, HPAccountI3D, HPAccountContactI3D); bl.AddPartnerTooAccount(StadtvTuttlAccountI3D, HPAccountI3D, HPAccountContactI3D); bl.AddPartnerTooAccount(CelosSoftAccountI3D, HPAccountI3D, HPAccountContactI3D); bl.AddPartnerTooAccount(StadtvTuttlAccountI3D, CentronAccountI3D, CentronAccountContactI3D); } private void CreateDublicateRelationship(BLSession session) { var bl = session.GetBL(); bl.AddPartnerTooAccount(CentronAccountI3D, MicrosoftAccountI3D, MicrosoftAccountContactI3D); } private void UpdateRelationshipSettings(BLSession session) { var bl = session.GetBL(); var relationship = new AccountRelationshipDTO() { AccountI3D = StadtvTuttlAccountI3D, PartnerAccountI3D = MicrosoftAccountI3D, PartnerAccountContactI3D = MicrosoftAccountContactI3D, NotifyAtCrmActivities = true, NotifyAtOrders = true, IsTelekomDivePartner = true }; bl.UpdatePartnerInfo(relationship); } private void ValidateRelationships(BLSession session, int runCount) { var bl = session.GetBL(); var result = bl.GetAccountRelationships(new AccountRelationshipFilter() { FilterKind = AccountRelationshipFilterKind.GetAllPartners }); Verifier.Verify($"AccountRelationship_ValidateRelationships[{runCount}]_AllPartners", result); result = bl.GetAccountRelationships(new AccountRelationshipFilter() { FilterKind = AccountRelationshipFilterKind.GetRelationshipsForAccount, AccountI3D = MicrosoftAccountI3D }); Verifier.Verify($"AccountRelationship_ValidateRelationships[{runCount}]_RelationshipsMicrosoftGmbHAccount", result); result = bl.GetAccountRelationships(new AccountRelationshipFilter() { FilterKind = AccountRelationshipFilterKind.GetRelationshipsForAccount, AccountI3D = CentronAccountI3D }); Verifier.Verify($"AccountRelationship_ValidateRelationships[{runCount}]_RelationshipsCentronAccount", result); } private void SearchSpecificRelationships(BLSession session) { var bl = session.GetBL(); var result = bl.GetAccountRelationships(new AccountRelationshipFilter() { FilterKind = AccountRelationshipFilterKind.GetRelationshipsForAccount, AccountI3D = StadtvTuttlAccountI3D, IsNotifyAtCrmActivitiesActive = true }); Verifier.Verify("SearchSpecificRelationships", result); } private void RemoveRelationship(BLSession session) { var bl = session.GetBL(); bl.RemovePartnerFromAccount(CelosSoftAccountI3D, MicrosoftAccountI3D, null); } } }