Files
Masterarbeit/QuellCode/CentronERP/tests/Centron.Tests.EndToEnd/TicketTests/Ticket133940/Ticket133940Tests.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

137 lines
4.9 KiB
C#

using System.Collections.Generic;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Sales.Receipts.DataAndResults;
using Centron.BusinessLogic.WebServices.Accounts;
using Centron.BusinessLogic.WebServices.Sales.Receipts;
using Centron.Data.Entities.Sales.Receipts.Offers.OfferImport;
using Centron.Data.WebServices.Sales.Receipts.Offers;
using Centron.Interfaces;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using CentronSoftware.Centron.WebServices.Entities.CustomerArea.CustomerToArticle;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.TicketTests.Ticket133940;
public class Ticket133940Tests : EndToEndTest
{
public Ticket133940Tests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
this.Verifier.Settings.CleanupProperty<ReceiptOfferItemDTO>(f => f.ManufacturerCode, RegexHelper.Guid, "Guid");
}
public const int CustomerI3D = 10006;
public const string OwnArticleManufacturerCode = "CF-30CTQAFBG";
public const string ExternalArticleManufacturerCode = "Q7830A#BAP";
public const string UnknownArticleManufacturerCode = "2444666668888888";
public const string CustomerArticleCode = "blabla-kunden-artikelcode-hehe";
public override void Execute()
{
this.PrepareDatabase();
var offer = this.CreateNewOffer();
this.ImportReceiptItems(offer);
}
private void PrepareDatabase()
{
// The HerstellerArtik are kinda broken - they all reference some invalid Hersteller (I3D column)
// So fix one article up, so it can be found and used in CreateReceiptItemsFromImport
this.Sql("UPDATE dbo.HerstellerArtik SET I3D = 49 WHERE I3D0 = 4771711");
// Create a customer article-code row
this.WithSession(session =>
{
session.GetBL<AccountWebServiceBL>().SaveCustomerArticle(new CustomerArticleDTO
{
CustomerI3D = CustomerI3D,
ArticleI3D = 4359,
CustomerArticleCode = CustomerArticleCode,
});
});
}
private ReceiptOfferDTO CreateNewOffer()
{
using var session = new BLSession();
var newReceiptData = session.GetBL<ReceiptWebServiceBL>().CreateNewReceipt(
CentronObjectKindNumeric.OfferClass,
this.GetLoggedInUser(),
CustomerI3D,
new CreateReceiptData
{
IgnoreCallbacks = true,
},
addressI3D: null,
contactPersonI3D: null,
insertSalutationAndAgreement: false,
ignoreDefaultContract: true,
insertCustomerDiscount: false).ThrowIfError();
return (ReceiptOfferDTO)newReceiptData.Receipt;
}
private void ImportReceiptItems(ReceiptOfferDTO offer)
{
using var session = new BLSession();
var parsedData = new ParsedData
{
Positions = new List<ParsedPositionData>
{
// Case 1: We have a article with that manufacturer code
new ParsedPositionData
{
VendorCode = OwnArticleManufacturerCode,
Description = "Eigener Artikel",
PurchasePrice = 50,
SellPrice = 100,
},
// Case 2: We know this manufacturer-code as a external article
new ParsedPositionData
{
VendorCode = ExternalArticleManufacturerCode,
Description = "Externer Artikel",
PurchasePrice = 50,
SellPrice = 100,
},
// Case 3: A unknown manufacturer-code
new ParsedPositionData
{
VendorCode = UnknownArticleManufacturerCode,
Description = "Unbekannter Artikel",
PurchasePrice = 50,
SellPrice = 100,
},
// Case 4: A customer article-code
new ParsedPositionData
{
VendorCode = CustomerArticleCode,
Description = "Kunden Artikelcode",
PurchasePrice = 50,
SellPrice = 100,
},
// Case 5: No manufacturer-code at all
new ParsedPositionData
{
VendorCode = null,
Description = "Kein Herstellercode",
PurchasePrice = 50,
SellPrice = 100
},
},
DescriptionKind = DescriptionKind.Source,
};
var importedItems = session.GetBL<ReceiptItemWebServiceBL>().CreateReceiptItemsFromImport(
offer,
this.GetLoggedInUser(),
parsedData).ThrowIfError();
this.Verifier.Verify("ImportedItems", importedItems);
}
}