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
106 lines
4.5 KiB
C#
106 lines
4.5 KiB
C#
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Administration;
|
|
using Centron.BusinessLogic.Administration.Settings;
|
|
using Centron.BusinessLogic.DocuBoard;
|
|
using Centron.BusinessLogic.EmployeeArea;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Data.Entities.DocuBoard;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using CentronSoftware.Centron.WebServices.Entities.Administration.Updates;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.UpdateAvailableNotification
|
|
{
|
|
public class UpdateAvailableNotificationTest : EndToEndTest
|
|
{
|
|
public UpdateAvailableNotificationTest(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.PreparePackagesTable();
|
|
|
|
// Now there is only the c-entron.NET package in the database
|
|
// It has 2 versions:
|
|
// 2.0.2004.4
|
|
// 2.0.2005.22
|
|
|
|
const int CurrentAppUserI3D = 11;
|
|
const int CurrentEmployeeI3D = 22;
|
|
|
|
const int OtherAppUserI3D = 14;
|
|
|
|
// Test ShowToAllEmployees
|
|
this.UpdateSettings(UpdateAvailableNotificationKind.ShowToAllEmployees, null);
|
|
this.TestAvailableUpdates("ShowToAllEmployeesCurrentVersion1_0_0_0", "1.0.0.0", CurrentAppUserI3D);
|
|
|
|
// Test NoNotification
|
|
this.UpdateSettings(UpdateAvailableNotificationKind.NoNotification, null);
|
|
this.TestAvailableUpdates("NoNotification", "1.0.0.0", CurrentAppUserI3D);
|
|
|
|
// Test ShowToSelectedEmployees
|
|
this.UpdateSettings(UpdateAvailableNotificationKind.ShowToSelectedEmployees, new List<int> { CurrentEmployeeI3D });
|
|
this.TestAvailableUpdates("CurrentVersionIsSuperOldUpdateExpected", "1.0.0.0", CurrentAppUserI3D);
|
|
this.TestAvailableUpdates("CurrentVersionIsOld2002UpdateExpected", "2.0.2002.0", CurrentAppUserI3D);
|
|
this.TestAvailableUpdates("CurrentVersionIsOld2004UpdateExpected", "2.0.2004.0", CurrentAppUserI3D);
|
|
this.TestAvailableUpdates("CurrentVersionIsOld2005UpdateExpected", "2.0.2005.0", CurrentAppUserI3D);
|
|
this.TestAvailableUpdates("CurrentVersionIsNew2006NoUpdateExpected", "2.0.2006.0", CurrentAppUserI3D);
|
|
|
|
this.TestAvailableUpdates("OtherUserNoUpdateExpected", "1.0.0.0", OtherAppUserI3D);
|
|
this.TestAvailableUpdates("OtherApplicationNoUpdateExpected", "2.0.2006.0", CurrentAppUserI3D, UpdateAvailableApplication.CentronDelphi);
|
|
|
|
// Test ShowToAdministrators
|
|
this.UpdateSettings(UpdateAvailableNotificationKind.ShowToAdministrators, null);
|
|
this.TestAvailableUpdates("Admin_CurrentVersionIsOld2005UpdateExpected", "2.0.2005.0", CurrentAppUserI3D);
|
|
this.TestAvailableUpdates("Admin_CurrentVersionIsNew2006NoUpdateExpected", "2.0.2006.0", CurrentAppUserI3D);
|
|
}
|
|
|
|
private void PreparePackagesTable()
|
|
{
|
|
UpdateAvailableNotificationBL.UseAlphaPackages = false;
|
|
|
|
UpdateAvailableNotificationBL.CustomGetPackageVersions = (packageName) =>
|
|
{
|
|
if (packageName is "c-entron.NET")
|
|
return new List<Version>
|
|
{
|
|
Version.Parse("2.0.2004.4"),
|
|
Version.Parse("2.0.2005.22")
|
|
};
|
|
|
|
return new List<Version>();
|
|
};
|
|
}
|
|
|
|
private void TestAvailableUpdates(string name, string currentVersion, int employeeI3D, UpdateAvailableApplication kind = UpdateAvailableApplication.CentronNET)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == employeeI3D);
|
|
var updates = session.GetBL<UpdateAvailableNotificationBL>().GetAvailableUpdates(kind, currentVersion, new LoggedInUser(user));
|
|
|
|
this.Verifier.Verify(name, updates);
|
|
}
|
|
}
|
|
|
|
private void UpdateSettings(UpdateAvailableNotificationKind kind, List<int> employeeI3Ds)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<AppSettingsGroupBL>().UpdateUpdateAvailableNotificationSettings(new UpdateAvailableNotificationSettingsDTO
|
|
{
|
|
EmployeeI3Ds = employeeI3Ds,
|
|
NotificationKind = kind
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|