using System; using System.Collections.Generic; using Centron.BusinessLogic; using Centron.BusinessLogic.WebServices.Accounts.AccountContracts; using Centron.Interfaces.Accounts.AccountContracts; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Accounts.AccountContracts; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Account.AccountContracts { public class AccountContractTests : EndToEndTest { public AccountContractTests(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 accountContractBL = session.GetBL(); CreateAccountContract(accountContractBL); CreateAccountContractFailing(accountContractBL); GetAccountContractByI3D(accountContractBL); // insert additional contracts CreateAdditionalAccountContracts(accountContractBL); GetAccountContracts(accountContractBL); } } private void CreateAccountContract(AccountContractWebServiceBL accountContractBL) { var newAccountContract = CreateTestAccountContract(); var saveResult = accountContractBL.SaveAccountContract(this.GetLoggedInUser(), newAccountContract); this.Verifier.Verify("SaveNewAccountContract_Successful", saveResult); } private void CreateAccountContractFailing(AccountContractWebServiceBL accountContractBL) { var newAccountContract = new AccountContractDTO(); var saveResult = accountContractBL.SaveAccountContract(this.GetLoggedInUser(), newAccountContract); this.Verifier.Verify("SaveNewAccountContract_Failing", saveResult); } private void GetAccountContractByI3D(AccountContractWebServiceBL accountContractBL) { var result = accountContractBL.GetAccountContractByI3D(this.GetLoggedInUser(), 1); this.Verifier.Verify("GetAccountContractByI3D_Result", result); } private void GetAccountContracts(AccountContractWebServiceBL accountContractBL) { var filter = new GetAccountContractsFilter(); filter.IsActive = true; filter.AccountI3Ds = new List { 1029 }; filter.BranchI3Ds = new List { 0 }; filter.AccountContractKindI3Ds = new List { 1 }; var result = accountContractBL.GetAccountContracts(this.GetLoggedInUser(), filter); this.Verifier.Verify("GetAccountContracts", result); } private void CreateAdditionalAccountContracts(AccountContractWebServiceBL accountContractBL) { var newAccountContract = CreateTestAccountContract(); newAccountContract.Name = "Handy Vertrag Thomas Bauer"; newAccountContract.BranchI3D = 1; accountContractBL.SaveAccountContract(this.GetLoggedInUser(), newAccountContract); newAccountContract = CreateTestAccountContract(); newAccountContract.Name = "Handy Vertrag Sandra Hallow"; newAccountContract.BranchI3D = 0; newAccountContract.IsClosed = true; accountContractBL.SaveAccountContract(this.GetLoggedInUser(), newAccountContract); newAccountContract = CreateTestAccountContract(); newAccountContract.Name = "Handy Vertrag Klara Walz"; newAccountContract.BranchI3D = 0; newAccountContract.IsClosed = false; accountContractBL.SaveAccountContract(this.GetLoggedInUser(), newAccountContract); } private AccountContractDTO CreateTestAccountContract() { var accountContract = new AccountContractDTO(); accountContract.ReferenceNumber = "Ref123"; accountContract.Date = new DateTime(2021, 2, 5); accountContract.AccountI3D = 1029; accountContract.Name = "Handy Vertrag James Müller"; accountContract.ContractBegin = new DateTime(2021,1,1); accountContract.AutomatedProlongation = true; accountContract.Prolongation = 12; accountContract.BranchI3D = 0; accountContract.NetTotalPrice = 40; accountContract.GrossTotalPrice = 47.6m; accountContract.CurrencyI3D = 1; accountContract.CurrencyFactor = 1; accountContract.CurrencyString = "€"; accountContract.AdditionalText = "Telekom MagentaMobil M"; accountContract.Email = "miller@telekom.de"; accountContract.CountryI3D = 1; accountContract.AccountContractKindI3D = 1; return accountContract; } } }