Files
Masterarbeit/QuellCode/CentronERP/tests/Centron.Tests.EndToEnd/Tests/Rebooking/RebookingTest.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

139 lines
5.9 KiB
C#

using System.Security.Cryptography.X509Certificates;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Warehousing;
using Centron.BusinessLogic.WebServices.Warehousing;
using Centron.DAO;
using Centron.DAO.UserTypes;
using Centron.Data.Entities.Logistics.Warehousing;
using Centron.Data.Entities.Warehousing;
using Centron.Data.Entities.Warehousing.StockManagement;
using Centron.Data.WebServices.Logistics.Warehousing;
using Centron.Data.WebServices.Warehousing.StockManagement;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using CentronSoftware.Centron.WebServices.Entities.Logistics.Warehousing;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Rebooking;
public class RebookingTest : EndToEndTest
{
private const int ARTICLE1 = 50; //ArticleCode 9673A003 -> some scanner
private const int ARTICLE2 = 92; // ArticleCode CB436A -> some printer cartridge
private const int Stock1 = 6; // Umbuchungslager
private const int Stock2 = 2; // RAM Sperrlager Eigenbesitz
private const int StorageLocation1 = 6; // 1.0 -> from Stock1
private const int StorageLocation2 = 7; // 2.0 -> from Stock1
public RebookingTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
this.Verifier.Settings.IgnoreColumn("AngelegtAm");
//fix the storage places, they don't have a secondary stock i3d set
this.Sql($"UPDATE Lagerort SET NebenlagerI3D = {Stock1}");
}
public override void Execute()
{
this.BookArticle();
this.RebookArticles();
}
private void BookArticle()
{
//add some article to the stock
using (BLSession session = new BLSession())
{
session.GetBL<SecondStockArticleWebServiceBL>().StockBookOrBookout(
true,
ARTICLE1,
Stock1,
100d,
"I installed a motion sensor on my toilet that tells a joke everytime you poop.",
GetLoggedInUser().User.I3D).ThrowIfError();
}
this.Verifier.VerifySql("01_AddedStocks", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock1}");
//remove some article from the stock
using (BLSession session = new BLSession())
{
session.GetBL<SecondStockArticleWebServiceBL>().StockBookOrBookout(
false,
ARTICLE1,
Stock1,
50d,
"Just for shits and giggles.",
GetLoggedInUser().User.I3D).ThrowIfError();
}
this.Verifier.VerifySql("02_RemovedStocks", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock1}");
//add some article to another stock
using (BLSession session = new BLSession())
{
session.GetBL<SecondStockArticleWebServiceBL>().StockBookOrBookout(
true,
ARTICLE1,
Stock2,
300d,
"After a while I uninstalled it. Being the butt of a joke really stinks.",
GetLoggedInUser().User.I3D).ThrowIfError();
}
this.Verifier.VerifySql("03_AddedToAnotherStock", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock2}");
using (BLSession session = new BLSession())
{
var logs = session.GetBL<ArticleLogWebServiceBL>().GetArticleLogs(new ArticleLogFilter()
{
ArticleI3Ds = new[] { ARTICLE1, ARTICLE2 }
});
this.Verifier.Verify("4_ArticleLogsAfter", logs);
}
}
private void RebookArticles()
{
//we simply book some articles from one stock to another stock and see what happens
using (BLSession session = new BLSession())
{
session.GetBL<SecondStockArticleWebServiceBL>().RebookStockArticle(Stock2, Stock1, StorageLocation1, null, ARTICLE1, 10, this.GetLoggedInUser()).ThrowIfError();
}
this.Verifier.VerifySql($"05_Booked_From_{Stock2}_To_{Stock1}", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock1} AND ArtikelI3D = {ARTICLE1}");
this.Verifier.VerifySql($"06_Booked_From_{Stock2}_To_{Stock1}", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock2} AND ArtikelI3D = {ARTICLE1}");
//there is a bug in here, when we book something to a different storageLocation (like StorageLocation2) all amount from others locations are removed from their place (StorageLocation1) and added to the other
using (BLSession session = new BLSession())
{
session.GetBL<SecondStockArticleWebServiceBL>().RebookStockArticle(Stock2, Stock1, StorageLocation2, null, ARTICLE1, 10, this.GetLoggedInUser()).ThrowIfError();
}
this.Verifier.VerifySql($"07_Booked_From_{Stock2}_To-{Stock1}", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock1} AND ArtikelI3D = {ARTICLE1}");
this.Verifier.VerifySql($"08_Booked_From_{Stock2}_To-{Stock1}", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock2} AND ArtikelI3D = {ARTICLE1}");
using (BLSession session = new BLSession())
{
session.GetBL<SecondStockArticleWebServiceBL>().RebookStockArticle(Stock2, Stock1, StorageLocation1, null, ARTICLE1, 10, this.GetLoggedInUser()).ThrowIfError();
}
this.Verifier.VerifySql($"09_Booked_From_{Stock2}_To-{Stock1}", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock1} AND ArtikelI3D = {ARTICLE1}");
this.Verifier.VerifySql($"10_Booked_From_{Stock2}_To-{Stock1}", $"SELECT * FROM NebenlagerArtikel WHERE NebenlagerI3D = {Stock2} AND ArtikelI3D = {ARTICLE1}");
using (BLSession session = new BLSession())
{
var logs = session.GetBL<ArticleLogWebServiceBL>().GetArticleLogs(new ArticleLogFilter()
{
ArticleI3Ds = new[] { ARTICLE1, ARTICLE2 }
});
this.Verifier.Verify("11_ArticleLogsAfterRebooking", logs);
}
}
}