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
154 lines
7.0 KiB
C#
154 lines
7.0 KiB
C#
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Administration.Logins;
|
|
using Centron.Data.Entities.Administration;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Data.Entities.Ticketing;
|
|
using Centron.Interfaces.Administration.Logins;
|
|
using Centron.Interfaces.BL;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.ConnectionTickets
|
|
{
|
|
public class ConnectionTicketsTests : EndToEndTest
|
|
{
|
|
public ConnectionTicketsTests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.TestTicketCounts(LicenseUsageKind.PerUserAndPerMachine, ApplicationKind.Centron,
|
|
user1I3D: 11, user2I3D: 12,
|
|
countForUser1AfterUser1Created2Tickets: 2,
|
|
countForUser2AfterUser2Created1Ticket: 3,
|
|
countForUser1AfterUser2Created1Ticket: 3,
|
|
allowUserNull: true, countForUserNullAfterUser1And2Created3Tickets: 3,
|
|
user3I3D: 13, countForUser3AfterUser1And2Created3Tickets: 3);
|
|
|
|
this.TestTicketCounts(LicenseUsageKind.PerUser, ApplicationKind.ServiceBoard,
|
|
user1I3D: 11, user2I3D: 12,
|
|
countForUser1AfterUser1Created2Tickets: 0,
|
|
countForUser2AfterUser2Created1Ticket: 1, //They only see each others tickets, but not their own, there is always enough space for themselves to login again
|
|
countForUser1AfterUser2Created1Ticket: 1,
|
|
allowUserNull: false, countForUserNullAfterUser1And2Created3Tickets: -1,
|
|
user3I3D: 13, countForUser3AfterUser1And2Created3Tickets: 2); // The separate user3 sees the tickets from the other 2 users
|
|
|
|
this.TestOneWebAccountCanBeLoggedInToMultipleApplications();
|
|
}
|
|
|
|
private void TestTicketCounts(LicenseUsageKind expectedLicenseUsageKind, ApplicationKind application,
|
|
int user1I3D, int user2I3D,
|
|
int countForUser1AfterUser1Created2Tickets,
|
|
int countForUser2AfterUser2Created1Ticket,
|
|
int countForUser1AfterUser2Created1Ticket,
|
|
bool allowUserNull, int countForUserNullAfterUser1And2Created3Tickets,
|
|
int user3I3D, int countForUser3AfterUser1And2Created3Tickets)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
// The application should have the expected LicenseUsageKind
|
|
Assert.Equal(expectedLicenseUsageKind, application.LicenseUsageKind);
|
|
|
|
// So if one user logs in twice from different computers
|
|
var user1 = CommonMethodsHelper.GetUser(session, user1I3D);
|
|
this.CreateTicket(application, user1, "Computer1");
|
|
this.CreateTicket(application, user1, "Computer2");
|
|
|
|
// It should use up expectedCountOnlyUser1 licenses
|
|
var ticketCountInUseForUser1 = this.GetTicketCount(application, user1);
|
|
Assert.Equal(countForUser1AfterUser1Created2Tickets, ticketCountInUseForUser1);
|
|
|
|
// If another user logs in too
|
|
var user2 = CommonMethodsHelper.GetUser(session, user2I3D);
|
|
this.CreateTicket(application, user2, "Computer1");
|
|
|
|
// It should use up expectedCountWithUser2
|
|
var ticketCountInUseForUser2 = this.GetTicketCount(application, user2);
|
|
Assert.Equal(countForUser2AfterUser2Created1Ticket, ticketCountInUseForUser2);
|
|
|
|
// How about when the first user checks the count again
|
|
var ticketCountInUseForUser1Again = this.GetTicketCount(application, user1);
|
|
Assert.Equal(countForUser1AfterUser2Created1Ticket, ticketCountInUseForUser1Again);
|
|
|
|
// Actually, it can be NULL
|
|
if (allowUserNull)
|
|
{
|
|
var ticketCountInUseForNullUser = this.GetTicketCount(application, null);
|
|
Assert.Equal(countForUserNullAfterUser1And2Created3Tickets, ticketCountInUseForNullUser);
|
|
}
|
|
|
|
// For a separate user
|
|
var user3 = CommonMethodsHelper.GetUser(session, user3I3D);
|
|
var ticketCountInUseForUser3 = this.GetTicketCount(application, user3);
|
|
Assert.Equal(countForUser3AfterUser1And2Created3Tickets, ticketCountInUseForUser3);
|
|
}
|
|
}
|
|
|
|
private void TestOneWebAccountCanBeLoggedInToMultipleApplications()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = new LoggedInUser(new AppUser(), new Ticket
|
|
{
|
|
WebAccount = new WebAccount
|
|
{
|
|
I3D = 1
|
|
},
|
|
WebAccountI3D = 1
|
|
});
|
|
var webCartTicket = this.CreateTicket(ApplicationKind.WebCart, user, "Computer1");
|
|
var sboTicket = this.CreateTicket(ApplicationKind.ServiceBoardOnline, user, "Computer1");
|
|
|
|
var ticketCountWebCart = this.GetTicketCount(ApplicationKind.WebCart, user);
|
|
var ticketCountServiceBoardOnline = this.GetTicketCount(ApplicationKind.ServiceBoardOnline, user);
|
|
Assert.Equal(1, ticketCountWebCart);
|
|
Assert.Equal(1, ticketCountServiceBoardOnline);
|
|
|
|
Logout(webCartTicket);
|
|
ticketCountWebCart = this.GetTicketCount(ApplicationKind.WebCart, user);
|
|
ticketCountServiceBoardOnline = this.GetTicketCount(ApplicationKind.ServiceBoardOnline, user);
|
|
Assert.Equal(0, ticketCountWebCart);
|
|
Assert.Equal(1, ticketCountServiceBoardOnline);
|
|
|
|
Logout(sboTicket);
|
|
ticketCountServiceBoardOnline = this.GetTicketCount(ApplicationKind.ServiceBoardOnline, user);
|
|
Assert.Equal(0, ticketCountServiceBoardOnline);
|
|
}
|
|
|
|
}
|
|
|
|
private Ticket CreateTicket(ApplicationKind application, LoggedInUser user, string computer)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
return session.GetBL<TicketBL>().CreateNewTicket(
|
|
application,
|
|
application.LicenseGuid,
|
|
computer,
|
|
user.User,
|
|
user.WebAccount).ThrowIfError();
|
|
}
|
|
}
|
|
|
|
private void Logout(Ticket ticket)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<TicketBL>().RemoveTicket(ticket.TicketId);
|
|
}
|
|
}
|
|
|
|
|
|
private int GetTicketCount(ApplicationKind application, LoggedInUser user)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
return session.GetBL<TicketBL>().GetTicketCount(application.LicenseGuid, application.LicenseUsageKind, user);
|
|
}
|
|
}
|
|
}
|
|
} |