Files
Masterarbeit/QuellCode/CentronERP/tests/Centron.Tests.EndToEnd/Tests/ModuleCustomProperties/ModuleCustomPropertiesTests.cs
T
Christoph Schwörer f045b99a25 Codebasis als Dateien ins Arbeitsrepo statt als Gitlink
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
2026-08-26 07:43:51 +02:00

291 lines
13 KiB
C#

using Centron.BusinessLogic;
using Centron.BusinessLogic.WebServices.Administration.Customization;
using Centron.Common.TextCoding;
using Centron.DAO;
using Centron.Data.Entities.Administration.Customization;
using Centron.Data.WebServices.Administration.Customization;
using Centron.Interfaces;
using Centron.Interfaces.Administration.Customization;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using System;
using System.Collections.Generic;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.ModuleCustomProperties
{
public class ModuleCustomPropertiesTests : EndToEndTest
{
private CentronObjectKindNumeric _referenceObjectKind = CentronObjectKindNumeric.HelpdeskClass;
private int _referenceObjectI3D = 10491;
private string _testSecuriteyKey = "abcdedfghijklmnopqrstuvwxyz";
private Dictionary<CustomizationDataTypes, int> _propertyDataTypeToI3DMapping;
public ModuleCustomPropertiesTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
this._propertyDataTypeToI3DMapping = new Dictionary<CustomizationDataTypes, int>();
}
public override void Execute()
{
this.SaveCustomPropertyStructure();
this.GetCustomPropertyStructure();
this.SaveCustomPropertyValues();
this.GetCustomPropertyValues();
}
private void SaveCustomPropertyStructure()
{
using var session = new BLSession();
var result = session
.GetBL<ModuleCustomPropertyWebServiceBL>()
.SaveCustomPropertyStructure(
this.GetLoggedInUser(),
new List<ModuleCustomPropertyDTO>
{
new ModuleCustomPropertyDTO
{
Category = "cat",
DataType = CustomizationDataTypes.Hyperlink,
IsVisible = true,
Name = "most fitting subreddit",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 1,
},
new ModuleCustomPropertyDTO
{
Category = "cat",
DataType = CustomizationDataTypes.String,
IsVisible = true,
Name = "description",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 2,
},
new ModuleCustomPropertyDTO
{
Category = "dog",
DataType = CustomizationDataTypes.DateTime,
IsVisible = true,
Name = "date of first tail catching",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 3,
},
new ModuleCustomPropertyDTO
{
Category = "dog",
DataType = CustomizationDataTypes.Integer,
IsVisible = true,
Name = "number of legs",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 4,
},
new ModuleCustomPropertyDTO
{
Category = "trashpanda",
DataType = CustomizationDataTypes.Image,
IsVisible = false,
Name = "picture",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 4,
},
new ModuleCustomPropertyDTO
{
Category = "trashpanda",
DataType = CustomizationDataTypes.File,
IsVisible = false,
Name = "tax file",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 4,
},
new ModuleCustomPropertyDTO
{
Category = "trashpanda",
DataType = CustomizationDataTypes.EncryptedText,
IsVisible = false,
Name = "secret hideout password",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 4,
} ,
new ModuleCustomPropertyDTO
{
Category = "trashpanda",
DataType = CustomizationDataTypes.ComboBox,
IsVisible = false,
Name = "personality",
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
SortOrder = 4,
PossibleValues = new List<ModuleCustomPropertyPossibleValueDTO>
{
new ModuleCustomPropertyPossibleValueDTO
{
IsVisible = true,
Value = "cute"
},
new ModuleCustomPropertyPossibleValueDTO
{
IsVisible = true,
Value = "angery"
},
new ModuleCustomPropertyPossibleValueDTO
{
IsVisible = true,
Value = "trash"
},
}
}
},
this._referenceObjectKind,
this._referenceObjectI3D);
Assert.Equal(ResultStatus.Success, result.Status);
}
private void GetCustomPropertyStructure()
{
using var session = new BLSession();
var result = session
.GetBL<ModuleCustomPropertyWebServiceBL>()
.GetCustomPropertyStructureForModule(this.GetLoggedInUser(), new CustomPropertyFilter
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind
});
this.Verifier.Verify("ModuleCustomPropertyStructure", result);
// we save the type + the new I3Ds here so we can reuse the i3ds when saving values in later tests.
foreach (var currentProperty in result.Data)
{
if (this._propertyDataTypeToI3DMapping.ContainsKey(currentProperty.DataType))
continue;
this._propertyDataTypeToI3DMapping.Add(currentProperty.DataType, currentProperty.I3D);
}
}
private void SaveCustomPropertyValues()
{
using var session = new BLSession();
var textToBeEncrypted = "encryptedText";
var result = session
.GetBL<ModuleCustomPropertyValueWebServiceBL>()
.SaveCustomPropertyValues(
this.GetLoggedInUser(),
this._referenceObjectI3D,
this._referenceObjectKind,
new List<ModuleCustomPropertyValueDTO>
{
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.Hyperlink],
ValueString = "https://www.reddit.com/r/standardissuecat/",
},
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.String],
ValueString = "standard issue",
},
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.DateTime],
ValueDateTime = new DateTime(2020, 1, 1),
},
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.Integer],
ValueInteger = 3,
},
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.Image],
ValueBytes = new byte[20],
},
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.File],
ValueBytes = new byte[20],
ValueString = "trash_accounting_numbers.csv",
},
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
Sealed = true,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.EncryptedText],
ValueEncryptedString = textToBeEncrypted,
},
new ModuleCustomPropertyValueDTO
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind,
Sealed = true,
ModuleCustomPropertyI3D = this._propertyDataTypeToI3DMapping[CustomizationDataTypes.ComboBox],
ValueInteger = 1, // we can safely us I3D 1 here as this table is completely new
},
},
this._testSecuriteyKey);
Assert.Equal(ResultStatus.Success, result.Status);
// we want to test that the values actually get properly encrypted in the database
var encryptedText = new AESCryptoLogic().EncryptText(textToBeEncrypted, this._testSecuriteyKey);
this.Verifier.VerifyTable("EncryptedModuleCustomPropertyValueEntity", "ModuleCustomPropertyValues", $"ValueEncryptedString = '{encryptedText}'");
}
private void GetCustomPropertyValues()
{
using var session = new BLSession();
var result = session
.GetBL<ModuleCustomPropertyValueWebServiceBL>()
.GetCustomPropertyValues(new CustomPropertyValueFilter
{
ObjectI3D = this._referenceObjectI3D,
ObjectKind = this._referenceObjectKind
},
this._testSecuriteyKey);
this.Verifier.Verify("ModuleCustomPropertyValues", result);
}
}
}