using System.Collections.Generic; using Centron.BusinessLogic; using Centron.BusinessLogic.WebServices.Accounts.AccountContracts; using Centron.Interfaces.Accounts.AccountContracts; using Centron.Tests.EndToEnd.Infrastructure; using Centron.Tests.EndToEnd.Infrastructure.Verifier; using CentronSoftware.Centron.WebServices.Entities.Accounts.AccountContracts; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Account.AccountContracts { public class AccountContractKindTests : EndToEndTest { public AccountContractKindTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { Verifier.Settings.IgnoreProperty(f => f.CreatedVersion); Verifier.Settings.IgnoreProperty(f => f.ChangedVersion); Verifier.Settings.IgnoreProperty(f => f.CreatedDate); Verifier.Settings.IgnoreProperty(f => f.ChangedDate); } public override void Execute() { using (var session = new BLSession()) { var testedBL = session.GetBL(); CreateAccountContractKind(testedBL); CreateAccountContractKindFailing(testedBL); GetAccountContractKindByI3D(testedBL); // insert additional contracts CreateAdditionalAccountContractKinds(testedBL); GetAccountContractKinds(testedBL); CreateAccountContractFromKind(session.GetBL()); } } private void CreateAccountContractKind(AccountContractKindWebServiceBL testedBL) { var newEntity = CreateTestAccountContractKind(); var saveResult = testedBL.SaveAccountContractKind(this.GetLoggedInUser(), newEntity); this.Verifier.Verify("SaveNewAccountContractKind_Successful", saveResult); } private void CreateAccountContractKindFailing(AccountContractKindWebServiceBL testedBL) { var newEntity = new AccountContractKindDTO(); var saveResult = testedBL.SaveAccountContractKind(this.GetLoggedInUser(), newEntity); this.Verifier.Verify("SaveNewAccountContractKind_Failing", saveResult); } private void GetAccountContractKindByI3D(AccountContractKindWebServiceBL testedBL) { var result = testedBL.GetAccountContractKindByI3D(this.GetLoggedInUser(), 1); this.Verifier.Verify("GetAccountContractKindByI3D_Result", result); } private void GetAccountContractKinds(AccountContractKindWebServiceBL testedBL) { var filter = new GetAccountContractKindsFilter(); filter.IsActive = true; filter.BranchI3Ds = new List { 0 }; var result = testedBL.GetAccountContractKinds(this.GetLoggedInUser(), filter); this.Verifier.Verify("GetAccountContractKinds", result); } private void CreateAdditionalAccountContractKinds(AccountContractKindWebServiceBL testedBL) { var newEntity = CreateTestAccountContractKind(); newEntity.Name = "Vorlage 1"; newEntity.BranchI3D = 1; testedBL.SaveAccountContractKind(this.GetLoggedInUser(), newEntity); newEntity = CreateTestAccountContractKind(); newEntity.Name = "Vorlage 2"; newEntity.BranchI3D = 0; newEntity.IsDeleted = true; testedBL.SaveAccountContractKind(this.GetLoggedInUser(), newEntity); newEntity = CreateTestAccountContractKind(); newEntity.Name = "Vorlage 3"; newEntity.BranchI3D = 0; testedBL.SaveAccountContractKind(this.GetLoggedInUser(), newEntity); } private void CreateAccountContractFromKind(AccountContractWebServiceBL testedBL) { var verifier = new CentronVerifierSettings(); verifier.IgnoreProperty(f => f.CreatedVersion); verifier.IgnoreProperty(f => f.ChangedVersion); verifier.IgnoreProperty(f => f.CreatedDate); verifier.IgnoreProperty(f => f.ChangedDate); var result = testedBL.CreateAccountContractFromKind(this.GetLoggedInUser(), 1, 1029); Verifier.Verify("CreateAccountContractFromKind_WithAccountRef", result, verifier); result = testedBL.CreateAccountContractFromKind(this.GetLoggedInUser(), 1, null); Verifier.Verify("CreateAccountContractFromKind_WithoutAccountRef", result, verifier); } private AccountContractKindDTO CreateTestAccountContractKind() { var entity = new AccountContractKindDTO(); entity.Name = "Telekom Handy Vertrag"; entity.AutomatedProlongation = true; entity.Prolongation = 12; entity.BranchI3D = 0; entity.CountryI3D = 1; return entity; } } }