QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
622 lines
26 KiB
C#
622 lines
26 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Administration.Rights;
|
|
using Centron.BusinessLogic.WebServices.Accounts;
|
|
using Centron.BusinessLogic.WebServices.Accounts.Accounting;
|
|
using Centron.BusinessLogic.WebServices.Logos;
|
|
using Centron.BusinessLogic.WebServices.Sales.Customers;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Data.WebServices.Sales.Customers;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.Accounting;
|
|
using Centron.Interfaces.Accounts;
|
|
using Centron.Interfaces.BL;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using CentronSoftware.Centron.WebServices.Entities.Accounts;
|
|
using CentronSoftware.Centron.WebServices.Entities.Accounts.Accounting;
|
|
using CentronSoftware.Centron.WebServices.Entities.Logos;
|
|
using CentronSoftware.Centron.WebServices.Extensions;
|
|
using CentronSoftware.Centron.WebServices.RestRequests;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.Account
|
|
{
|
|
public class AccountTests : EndToEndTest
|
|
{
|
|
public AccountTests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
this.Verifier.Settings.IgnoreProperty<AccountDTO>(f => f.ChangedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountDTO>(f => f.ChangedDate);
|
|
this.Verifier.Settings.IgnoreProperty<AccountDTO>(f => f.CreatedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountDTO>(f => f.CreatedDate);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressDTO>(f => f.ChangedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressDTO>(f => f.ChangedDate);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressDTO>(f => f.CreatedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressDTO>(f => f.CreatedDate);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressContactDTO>(f => f.ChangedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressContactDTO>(f => f.ChangedDate);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressContactDTO>(f => f.CreatedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressContactDTO>(f => f.CreatedDate);
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.GetAccountUISettings();
|
|
this.SearchAccounts();
|
|
this.SearchAccountsOldStructucre();
|
|
var account = this.GetAccount();
|
|
//this should find zero logs
|
|
this.CheckLogs(account.I3D, "Logs_for_existing_Account");
|
|
this.ChangeAndSaveAccount(account);
|
|
this.CheckLogs(account.I3D, "Logs_for_existing_Account_after_Change");
|
|
|
|
var newCustomerI3DContact = this.GetNewCustomer(AccountTypeKind.Contact);
|
|
var newCustomerI3D = this.GetNewCustomer(AccountTypeKind.Customer);
|
|
this.GetNewCustomer(AccountTypeKind.Supplier);
|
|
|
|
this.ChangeCustomer(newCustomerI3DContact);
|
|
this.CheckLogs(newCustomerI3DContact, "Logs_for_Contact_after_Change");
|
|
this.AccountRightTest(newCustomerI3D);
|
|
|
|
this.GetAccountExcludeContactPicturesTest();
|
|
}
|
|
|
|
private void AccountRightTest(int newCustomerI3D)
|
|
{
|
|
// UserRightsConst.Sales.Customer.CustomerCommon.SaveCustomer.CREATE_ADDRESS
|
|
this.AccountCanCreateAddressTest();
|
|
//UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_LANGUAGE
|
|
this.AccountCanChangeAddressLanguageTest();
|
|
//UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_CURRENCY
|
|
this.AccountCanChangeAddressCurrencyTest();
|
|
//UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_INFO
|
|
this.AccountCanChangeCustomerInfoTest(newCustomerI3D);
|
|
//UserRightsConst.Sales.Customer.CustomerFinance.CREATE_NEW_Bank_Account
|
|
this.AccountCanCreateBankAccountTest(newCustomerI3D);
|
|
//UserRightsConst.Sales.Customer.CustomerFinance.EDIT_Bank_Account
|
|
this.AccountCanChangeBankAccountTest(newCustomerI3D);
|
|
}
|
|
|
|
private void AccountCanCreateAddressTest()
|
|
{
|
|
var user = this.GetLoggedInUser();
|
|
|
|
var account = this.GetAccountByFilter();
|
|
|
|
account.Addresses.Add(new AccountAddressDTO()
|
|
{
|
|
CountryI3D = 15,
|
|
Department = "Vienna",
|
|
City = "Vienna",
|
|
Zip = "1010",
|
|
Comment = "Has a better castle than france.",
|
|
Contacts = new List<AccountAddressContactDTO>()
|
|
});
|
|
|
|
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.SaveCustomer.CREATE_ADDRESS));
|
|
Assert.True(currentUserHasRightTrue);
|
|
|
|
RunTest("AccountCanCreateAddress_TRUE_Test", user, account);
|
|
|
|
// And add the "only-own" right
|
|
this.Sql($"DELETE FROM dbo.Sichtrus WHERE Recht = {UserRightsConst.Sales.Customer.CustomerCommon.SaveCustomer.CREATE_ADDRESS}");
|
|
|
|
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.SaveCustomer.CREATE_ADDRESS));
|
|
Assert.False(currentUserHasRightFalse);
|
|
|
|
RunTest("AccountCanCreateAddress_FALSE_Test", user, account);
|
|
}
|
|
|
|
private void AccountCanChangeAddressLanguageTest()
|
|
{
|
|
var user = this.GetLoggedInUser();
|
|
|
|
var account = this.GetAccountByFilter();
|
|
|
|
var address = account.Addresses.FirstOrDefault();
|
|
|
|
if (address != null)
|
|
address.LanguageI3D = 15;
|
|
|
|
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_LANGUAGE));
|
|
Assert.True(currentUserHasRightTrue);
|
|
|
|
RunTest("AccountCanChangeAddressLanguageTest_TRUE_Test", user, account);
|
|
|
|
// And add the "only-own" right
|
|
this.Sql($"DELETE FROM dbo.Sichtrus WHERE Recht = {UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_LANGUAGE}");
|
|
|
|
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_LANGUAGE));
|
|
Assert.False(currentUserHasRightFalse);
|
|
|
|
if (address != null)
|
|
address.LanguageI3D = 6;
|
|
|
|
RunTest("AccountCanChangeAddressLanguageTest_FALSE_Test", user, account);
|
|
}
|
|
|
|
private void AccountCanChangeAddressCurrencyTest()
|
|
{
|
|
var user = this.GetLoggedInUser();
|
|
|
|
var account = this.GetAccountByFilter();
|
|
|
|
var address = account.Addresses.FirstOrDefault();
|
|
|
|
if (address != null)
|
|
address.CurrencyI3D = 1;
|
|
|
|
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_CURRENCY));
|
|
Assert.True(currentUserHasRightTrue);
|
|
|
|
RunTest("AccountCanChangeAddressCurrencyTest_TRUE_Test", user, account);
|
|
|
|
// And add the "only-own" right
|
|
this.Sql($"DELETE FROM dbo.Sichtrus WHERE Recht = {UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_CURRENCY}");
|
|
|
|
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_ADDRESS_CURRENCY));
|
|
Assert.False(currentUserHasRightFalse);
|
|
|
|
if (address != null)
|
|
address.CurrencyI3D = 2;
|
|
|
|
RunTest("AccountCanChangeAddressCurrencyTest_FALSE_Test", user, account);
|
|
}
|
|
|
|
void RunTest(string name, LoggedInUser currentUser, AccountDTO account)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var saveResult = session.GetBL<AccountWebServiceBL>().SaveAccount(currentUser, account, true, false);
|
|
|
|
Assert.Equal(ResultStatus.Success, saveResult.Status);
|
|
Assert.NotNull(saveResult.Data);
|
|
|
|
this.Verifier.Verify(name, saveResult.Data);
|
|
}
|
|
}
|
|
|
|
private void AccountCanChangeCustomerInfoTest(int newCustomerI3D)
|
|
{
|
|
var user = this.GetLoggedInUser();
|
|
var account = this.GetAccountByFilter(newCustomerI3D);
|
|
AccountCustomerDTO customerData;
|
|
account.TryGetCustomerData(out customerData);
|
|
|
|
var logos = this.GetLogos(1, CentronObjectKindNumeric.Account);
|
|
var logo = logos.FirstOrDefault();
|
|
Assert.NotNull(logo);
|
|
|
|
logo.I3D = 0;
|
|
logo.ObjectI3D = customerData.Number;
|
|
logo.ObjectKind = CentronObjectKindNumeric.CustomerClass;
|
|
|
|
RunTest("AccountCanSaveInfoLogoTest", user, logo);
|
|
|
|
var logoCustomers = this.GetLogos(customerData.Number, CentronObjectKindNumeric.CustomerClass);
|
|
var logoCustomer = logos.FirstOrDefault();
|
|
Assert.NotNull(logo);
|
|
|
|
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_INFO));
|
|
Assert.True(currentUserHasRightTrue);
|
|
|
|
logoCustomer.IsDefault = false;
|
|
|
|
RunTest("AccountCanChangeCustomerInfoLogoTest_TRUE_Test", user, logoCustomer);
|
|
|
|
var customer = this.WithSession(f => f.GetBL<CustomerWebServiceBL>().GetCustomerByI3D(10000, user));
|
|
customer.Comment = "Speichern Can Change Customer Info Test";
|
|
customer.OfferInfo = "Offer Test Can Change Customer Info Test ohne Recht";
|
|
|
|
RunTest("AccountCanChangeCustomerInfoTest_TRUE_Test", user, customer);
|
|
|
|
// And add the "only-own" right
|
|
this.Sql($"DELETE FROM dbo.Sichtrus WHERE Recht = {UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_INFO}");
|
|
|
|
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerCommon.EditCustomer.EDIT_CUSTOMER_INFO));
|
|
Assert.False(currentUserHasRightFalse);
|
|
|
|
logo.IsDefault = false;
|
|
|
|
RunTest("AccountCanChangeCustomerInfoLogoTest_FALSE_Test", user, logoCustomer);
|
|
|
|
var customer2 = this.WithSession(f => f.GetBL<CustomerWebServiceBL>().GetCustomerByI3D(10000, user));
|
|
customer2.Comment = "Speichern Can Change Customer Info Test ohne Recht";
|
|
customer2.OfferInfo = "Offer Test Can Change Customer Info Test ohne Recht";
|
|
|
|
RunTest("AccountCanChangeCustomerInfoTest_FALSE_Test", user, customer2);
|
|
}
|
|
|
|
public IList<LogoDTO> GetLogos(int objectI3D, CentronObjectKindNumeric objectKind)
|
|
{
|
|
var filter = new GetLogosFilter
|
|
{
|
|
ObjectI3D = objectI3D,
|
|
ObjectKind = objectKind
|
|
};
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
return session.GetBL<LogosWebServiceBL>().GetLogos(filter).ToList();
|
|
}
|
|
}
|
|
|
|
void RunTest(string name, LoggedInUser currentUser, LogoDTO logo)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var saveResult = session.GetBL<LogosWebServiceBL>().SaveLogo(currentUser, logo);
|
|
|
|
if (saveResult.Status == ResultStatus.Success)
|
|
{
|
|
this.Verifier.Verify(name, saveResult.Data);
|
|
}
|
|
else
|
|
{
|
|
this.Verifier.Verify(name, saveResult);
|
|
}
|
|
}
|
|
}
|
|
|
|
void RunTest(string name, LoggedInUser currentUser, CustomerDTO customer)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var saveResult = session.GetBL<CustomerWebServiceBL>().SaveCustomer(currentUser.User, customer);
|
|
|
|
Assert.Equal(ResultStatus.Success, saveResult.Status);
|
|
|
|
this.Verifier.Verify(name, saveResult.Data);
|
|
}
|
|
}
|
|
|
|
|
|
private void AccountCanCreateBankAccountTest(int newCustomerI3D)
|
|
{
|
|
var user = this.GetLoggedInUser();
|
|
|
|
var account = this.GetAccountByFilter(newCustomerI3D);
|
|
AccountCustomerDTO customerData;
|
|
account.TryGetCustomerData(out customerData);
|
|
|
|
var newBankAccount = new BankAccountDTO()
|
|
{
|
|
IsDefault = true,
|
|
Caption = "Neu Französische Bank",
|
|
Bankname = "Neu Französische Bank",
|
|
Street = "Nouvelle-Aquitaine 9",
|
|
City = "Meyrals",
|
|
PaymentType = BankAccountPaymentType.BankAccount,
|
|
BankCodeNumber = "DE",
|
|
AccountNumber = $"{account.Number}",
|
|
CountryI3D = 6,
|
|
Iban = "DE02120300000000202051",
|
|
BankConnectionNumber = "2",
|
|
Bic = "021203000",
|
|
AuthorizationDate = new DateTime(2023, 4, 22),
|
|
ValidFrom = new DateTime(2020, 4, 22),
|
|
ValidTo = new DateTime(2030, 4, 22),
|
|
LastUsed = new DateTime(2023, 4, 22),
|
|
DirectDebitType = SepaDirectDebitType.First,
|
|
AuthorizationNumber = "123654",
|
|
Comment = "Französischer Test",
|
|
ObjectI3D = customerData.Number,
|
|
ObjectKind = 0,
|
|
Status = 1
|
|
};
|
|
|
|
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerFinance.CREATE_NEW_Bank_Account));
|
|
Assert.True(currentUserHasRightTrue);
|
|
|
|
RunTest("AccountCanCreateBankAccountLogoTest_TRUE_Test", user, newBankAccount);
|
|
|
|
// And add the "only-own" right
|
|
this.Sql($"DELETE FROM dbo.Sichtrus WHERE Gruppe = 6 And Recht = {UserRightsConst.Sales.Customer.CustomerFinance.CREATE_NEW_Bank_Account}");
|
|
|
|
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerFinance.CREATE_NEW_Bank_Account));
|
|
Assert.False(currentUserHasRightFalse);
|
|
|
|
RunTest("AccountCanCreateBankAccountLogoTest_FALSE_Test", user, newBankAccount);
|
|
}
|
|
|
|
private void AccountCanChangeBankAccountTest(int newCustomerI3D)
|
|
{
|
|
var user = this.GetLoggedInUser();
|
|
|
|
var account = this.GetAccountByFilter(newCustomerI3D);
|
|
AccountCustomerDTO customerData;
|
|
account.TryGetCustomerData(out customerData);
|
|
|
|
BankAccountDTO bankAccount;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var getResult = session.GetBL<BankAccountWebserviceBL>().GetBankAccountsFromCustomer(new GetBankAccountsFromCustomerRequest
|
|
{
|
|
CustomerI3D = customerData.Number,
|
|
});
|
|
|
|
bankAccount = getResult.FirstOrDefault();
|
|
}
|
|
|
|
Assert.NotNull(bankAccount);
|
|
|
|
bankAccount.City = "Vienna";
|
|
bankAccount.Comment = "Geändert für Test True";
|
|
|
|
|
|
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerFinance.EDIT_Bank_Account));
|
|
Assert.True(currentUserHasRightTrue);
|
|
|
|
RunTest("AccountCanChangeBankAccountTest_TRUE_Test", user, bankAccount);
|
|
|
|
// And add the "only-own" right
|
|
this.Sql($"DELETE FROM dbo.Sichtrus WHERE Gruppe = 6 And Recht = {UserRightsConst.Sales.Customer.CustomerFinance.EDIT_Bank_Account}");
|
|
|
|
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Sales.Customer.CustomerFinance.EDIT_Bank_Account));
|
|
Assert.False(currentUserHasRightFalse);
|
|
|
|
bankAccount.City = "Ulm";
|
|
bankAccount.Comment = "Geändert für Test False";
|
|
|
|
RunTest("AccountCanChangeBankAccountTest_FALSE_Test", user, bankAccount);
|
|
}
|
|
|
|
void RunTest(string name, LoggedInUser currentUser, BankAccountDTO bankAccount)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var saveResult = session.GetBL<BankAccountWebserviceBL>().SaveBankAccount(bankAccount, currentUser);
|
|
|
|
if (saveResult.Status == ResultStatus.Success)
|
|
{
|
|
this.Verifier.Verify(name, saveResult.Data);
|
|
}
|
|
else
|
|
{
|
|
this.Verifier.Verify(name, saveResult);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void GetAccountUISettings()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var accountUISettings = session.GetBL<AccountWebServiceBL>().GetAccountUiSettings(11);
|
|
|
|
Assert.Equal(ResultStatus.Success, accountUISettings.Status);
|
|
Assert.NotNull(accountUISettings.Data);
|
|
|
|
this.Verifier.Verify("AccountUISettings", accountUISettings.Data);
|
|
}
|
|
}
|
|
|
|
private void SearchAccounts()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var filter = new AccountSearchFilter
|
|
{
|
|
IsActive = true,
|
|
IsDefaultAddress = true,
|
|
IsDefaultAddressContact = true,
|
|
};
|
|
|
|
var searchResult = session.GetBL<AccountSearchWebServiceBL>().SearchAccountsThroughPaging(this.GetLoggedInUser(), filter, 1, int.MaxValue);
|
|
|
|
Assert.Equal(ResultStatus.Success, searchResult.Status);
|
|
Assert.NotNull(searchResult.Data);
|
|
|
|
this.Verifier.Verify("AccountSearch", searchResult.Data);
|
|
}
|
|
}
|
|
private void SearchAccountsOldStructucre()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var filter = new AccountSearchFilter
|
|
{
|
|
IsActive = true,
|
|
IsDefaultAddress = true,
|
|
IsDefaultAddressContact = true,
|
|
ForceSearchInOldStructure = true
|
|
};
|
|
|
|
// To test search without paging, set page and entriesPerPage to 0. Important test case!!
|
|
var searchResult = session.GetBL<AccountSearchWebServiceBL>().SearchAccountsThroughPaging(this.GetLoggedInUser(), filter, 0, 0);
|
|
|
|
Assert.Equal(ResultStatus.Success, searchResult.Status);
|
|
Assert.NotNull(searchResult.Data);
|
|
|
|
this.Verifier.Verify("AccountSearchOldStructure", searchResult.Data);
|
|
}
|
|
}
|
|
|
|
private AccountDTO GetAccount()
|
|
{
|
|
var account = this.GetAccountByFilter();
|
|
|
|
this.Verifier.Verify("GetAccount", account);
|
|
|
|
return account;
|
|
|
|
}
|
|
|
|
private AccountDTO GetAccountByFilter(int? accountI3D = null)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var filter = new AccountFilter
|
|
{
|
|
AccountI3D = accountI3D ?? 1037
|
|
};
|
|
|
|
var accountResult = session.GetBL<AccountWebServiceBL>().GetAccount(this.GetLoggedInUser(), filter, true);
|
|
|
|
Assert.Equal(ResultStatus.Success, accountResult.Status);
|
|
Assert.NotNull(accountResult.Data);
|
|
|
|
if (accountI3D != null)
|
|
{
|
|
this.Verifier.Verify($"GetAccount_{accountI3D}", accountResult.Data);
|
|
}
|
|
|
|
return accountResult.Data;
|
|
}
|
|
}
|
|
|
|
private void ChangeAndSaveAccount(AccountDTO account)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
account.Comment = "Geändert für Test";
|
|
account.Phone = "111222333";
|
|
account.Email = "account@Test.test";
|
|
account.Name += 1;
|
|
account.Matchcode = "uwu";
|
|
|
|
var saveResult = session.GetBL<AccountWebServiceBL>().SaveAccount(this.GetLoggedInUser(), account, true, false);
|
|
|
|
Assert.Equal(ResultStatus.Success, saveResult.Status);
|
|
Assert.NotNull(saveResult.Data);
|
|
|
|
this.Verifier.Verify("SaveAccount", saveResult.Data);
|
|
}
|
|
}
|
|
|
|
private int GetNewCustomer(AccountTypeKind kind)
|
|
{
|
|
using (var bl = new BLSession())
|
|
{
|
|
var account = bl.GetBL<AccountWebServiceBL>().CreateNewAccount(this.GetLoggedInUser(), null, kind, true);
|
|
|
|
Assert.Equal(ResultStatus.Success, account.Status);
|
|
Assert.NotNull(account.Data);
|
|
|
|
this.Verifier.Verify($"GetNew{kind.ToString()}", account.Data);
|
|
|
|
account.Data.Name = "Peter Lustig";
|
|
var savedAccount = bl.GetBL<AccountWebServiceBL>().SaveAccount(this.GetLoggedInUser(), account.Data,true, false).ThrowIfError();
|
|
return savedAccount.I3D;
|
|
}
|
|
}
|
|
|
|
private void CheckLogs(int accountI3D, string nameForVerifier)
|
|
{
|
|
var filter = new AccountLogFilter()
|
|
{
|
|
AccountI3Ds = new List<int> { accountI3D }
|
|
};
|
|
|
|
var logs = this.WithSession(f => f.GetBL<AccountWebServiceBL>().GetAccountLogsByFilter(filter)).ThrowIfError().OrderBy(f => f.I3D);
|
|
|
|
this.Verifier.Verify(nameForVerifier, logs);
|
|
}
|
|
|
|
private void ChangeCustomer(int accountI3D)
|
|
{
|
|
var filter = new AccountFilter
|
|
{
|
|
AccountI3D = accountI3D
|
|
};
|
|
|
|
using (var bl = new BLSession())
|
|
{
|
|
var customer = bl.GetBL<AccountWebServiceBL>().GetAccount(this.GetLoggedInUser(), filter, true).ThrowIfError();
|
|
|
|
var france = new AccountAddressDTO()
|
|
{
|
|
CountryI3D = 6,
|
|
CurrencyI3D = 6,
|
|
LanguageI3D = 6,
|
|
Department = "Nouvelle-Aquitaine",
|
|
City = "Meyrals",
|
|
Zip = "24220",
|
|
Comment = "Has a nice castle"
|
|
};
|
|
|
|
var ludwig = new AccountAddressContactDTO()
|
|
{
|
|
Firstname = "Ludwig XVI",
|
|
Lastname = "Of France",
|
|
Comment = "acts a bit headless",
|
|
Birthday = new DateTime(1754, 08, 23),
|
|
Email1 = "lastKing@France.com",
|
|
IsMailingAtEmail1Active = true
|
|
};
|
|
|
|
france.Contacts = new List<AccountAddressContactDTO> { ludwig };
|
|
customer.Addresses = new List<AccountAddressDTO> { france };
|
|
|
|
customer.Name = "Robespierre & Co.";
|
|
customer.Comment = "Sharp blades, from razor to guillotine";
|
|
|
|
bl.GetBL<AccountWebServiceBL>().SaveAccount(this.GetLoggedInUser(), customer, true, false);
|
|
}
|
|
}
|
|
|
|
private void GetAccountExcludeContactPicturesTest()
|
|
{
|
|
var accountI3D = 4;
|
|
this.PrepareAccountAddressContacts(accountI3D);
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var filter01 = new AccountFilter { AccountI3D = accountI3D };
|
|
|
|
var accountResult01 = session.GetBL<AccountWebServiceBL>().GetAccount(this.GetLoggedInUser(), filter01, true);
|
|
|
|
Assert.Equal(ResultStatus.Success, accountResult01.Status);
|
|
Assert.NotNull(accountResult01.Data);
|
|
Assert.NotNull(accountResult01.Data.Addresses);
|
|
|
|
var contacts01 = accountResult01.Data.Addresses?.Where(f => f.Contacts != null).SelectMany(f => f.Contacts).ToList();
|
|
|
|
foreach (var contacts in contacts01)
|
|
{
|
|
Assert.NotNull(contacts.Picture);
|
|
Assert.True(contacts.Picture.Length > 0);
|
|
}
|
|
|
|
var filter02 = new AccountFilter { AccountI3D = accountI3D, ExcludeContactPictures = true };
|
|
|
|
var accountResult02 = session.GetBL<AccountWebServiceBL>().GetAccount(this.GetLoggedInUser(), filter02, true);
|
|
|
|
Assert.Equal(ResultStatus.Success, accountResult02.Status);
|
|
Assert.NotNull(accountResult02.Data);
|
|
Assert.NotNull(accountResult02.Data.Addresses);
|
|
|
|
foreach (var contacts in accountResult02.Data.Addresses?.Where(f => f.Contacts != null).SelectMany(f => f.Contacts))
|
|
{
|
|
Assert.NotNull(contacts.Picture);
|
|
Assert.True(contacts.Picture.Length == 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void PrepareAccountAddressContacts(int accountI3D)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var filter = new AccountFilter { AccountI3D = accountI3D };
|
|
var accountResult01 = session.GetBL<AccountWebServiceBL>().GetAccount(this.GetLoggedInUser(), filter, true);
|
|
|
|
Assert.Equal(ResultStatus.Success, accountResult01.Status);
|
|
Assert.NotNull(accountResult01.Data);
|
|
Assert.NotNull(accountResult01.Data.Addresses);
|
|
|
|
var contacts = accountResult01.Data.Addresses?.Where(f => f.Contacts != null).SelectMany(f => f.Contacts).ToList();
|
|
contacts.ForEach(f => f.Picture = new byte[] { 1, 2, 3, 4, 5 });
|
|
session.GetBL<AccountAddressContactWebServiceBL>().SaveContacts(this.GetLoggedInUser(), contacts);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|