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
137 lines
4.9 KiB
C#
137 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Administration.Logins;
|
|
using Centron.BusinessLogic.EmployeeArea;
|
|
using Centron.BusinessLogic.Mail.Factory;
|
|
using Centron.DAO;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Tests.EndToEnd.Infrastructure.Fixtures;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
using Xunit.Extensions.AssemblyFixture;
|
|
using Centron.Core;
|
|
using Centron.Interfaces.Administration.Logins;
|
|
using Centron.Interfaces.BL;
|
|
|
|
namespace Centron.Tests.EndToEnd.Infrastructure
|
|
{
|
|
public abstract class EndToEndTest : CentronTest,
|
|
IAssemblyFixture<DatabaseAssemblyFixture>,
|
|
IAssemblyFixture<LicensingAssemblyFixture>,
|
|
IAssemblyFixture<InitializeObjectMapperAssemblyFixture>
|
|
{
|
|
[Fact]
|
|
public abstract void Execute();
|
|
|
|
protected LoggedInUser GetLoggedInUser(int userI3D = 11)
|
|
{
|
|
using var session = new BLSession();
|
|
return new LoggedInUser(session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == userI3D));
|
|
}
|
|
|
|
private Dictionary<int, string> _ticketId = new();
|
|
protected LoggedInUser GetLoggedInUserWebAccount(int webAccountI3D = 6)
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var webAccountAppUser = session.GetBL<AppUserBL>().GetAppUserForWebaccounts().ThrowIfError();
|
|
var emp = webAccountAppUser.Employee; //Make sure the employee is loaded too
|
|
var appUser = emp.AppUser; //Make sure this is loaded as well
|
|
var webAccount = session.GetBL<WebAccountBL>().GetWebAccountByI3D(webAccountI3D);
|
|
var rights = webAccount.WebRights.ToList(); //Make sure the rights are loaded too
|
|
|
|
var existingTicketId = this._ticketId.TryGetValue(webAccountI3D, out var i) ? i : null;
|
|
|
|
var ticket = existingTicketId switch
|
|
{
|
|
not null => session.GetBL<TicketBL>().GetTicket(existingTicketId).ThrowIfError(),
|
|
null => session.GetBL<TicketBL>().CreateNewTicket(
|
|
ApplicationKind.Developer,
|
|
LicenseGuids.Developer,
|
|
"Test-Device",
|
|
webAccountAppUser,
|
|
webAccount).ThrowIfError()
|
|
};
|
|
|
|
// Update web-account, to make sure we get current version of the web-account, with the current rights
|
|
ticket.WebAccount = webAccount;
|
|
|
|
this._ticketId[webAccountI3D] = ticket.TicketId;
|
|
|
|
return new LoggedInUser(webAccountAppUser, ticket);
|
|
}
|
|
|
|
public EndToEndTest(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
Guard.NotNull(testOutputHelper, nameof(testOutputHelper));
|
|
|
|
Database.RestoreFromSnapshot();
|
|
}
|
|
|
|
public void Sql(string statement, Action<IDbCommand> addParametersAction = null)
|
|
{
|
|
using (var session = new DAOSession())
|
|
{
|
|
session.Advanced.RawSqlAccess.ExecuteNonQueryTransactionSave(statement, addParametersAction).ThrowIfError();
|
|
}
|
|
}
|
|
|
|
public T Sql<T>(string statement, Action<IDbCommand> addParametersAction = null)
|
|
{
|
|
using (var session = new DAOSession())
|
|
{
|
|
return session.Advanced.RawSqlAccess.ExecuteScalarTransactionSave<T>(statement, addParametersAction).ThrowIfError();
|
|
}
|
|
}
|
|
|
|
public void ExecuteMatrix<T1>(T1[] input1, Action<T1> execute)
|
|
{
|
|
this.ExecuteMatrix<T1, object>(
|
|
input1,
|
|
new object[]{null},
|
|
(inputItem1, _) => execute(inputItem1));
|
|
}
|
|
|
|
public void ExecuteMatrix<T1, T2>(T1[] input1, T2[] input2, Action<T1, T2> execute)
|
|
{
|
|
this.ExecuteMatrix<T1, T2, object>(
|
|
input1,
|
|
input2,
|
|
new object[] {null},
|
|
(inputItem1, inputItem2, _) => execute(inputItem1, inputItem2));
|
|
}
|
|
|
|
public void ExecuteMatrix<T1, T2, T3>(T1[] input1, T2[] input2, T3[] input3, Action<T1, T2, T3> execute)
|
|
{
|
|
foreach (var inputItem1 in input1)
|
|
{
|
|
foreach (var inputItem2 in input2)
|
|
{
|
|
foreach (var inputItem3 in input3)
|
|
{
|
|
execute(inputItem1, inputItem2, inputItem3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void WithSession(Action<BLSession> action)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
action(session);
|
|
}
|
|
}
|
|
public T WithSession<T>(Func<BLSession, T> getter)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
return getter(session);
|
|
}
|
|
}
|
|
}
|
|
} |