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
192 lines
8.7 KiB
C#
192 lines
8.7 KiB
C#
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Administration.Settings;
|
|
using Centron.BusinessLogic.CentronNexus;
|
|
using Centron.BusinessLogic.WebServices.Administration.Documents.ReceiptComments;
|
|
using Centron.BusinessLogic.WebServices.Administration.FileManagement;
|
|
using Centron.BusinessLogic.WebServices.Sales.Receipts;
|
|
using Centron.Data.Entities.Administration.FileManagement;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.BL;
|
|
using Centron.Interfaces.Sales.Receipts;
|
|
using Centron.Interfaces.Sales.Receipts.WebReceipt;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using CentronSoftware.Centron.WebServices.Entities.Administration.FileManagement.SharedDocuments;
|
|
using System.IO;
|
|
using Centron.BusinessLogic.Mail;
|
|
using Centron.BusinessLogic.Mail.Factory;
|
|
using Centron.BusinessLogic.WebServices.Employee;
|
|
using Centron.Interfaces.Mail.Enums;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.WebReceipts;
|
|
|
|
public class WebReceiptTests : EndToEndTest
|
|
{
|
|
public WebReceiptTests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
this.Verifier.Settings.IgnoreProperty<SharedDocumentByTokenDTO>(f => f.SharedDocument.Token);
|
|
this.Verifier.Settings.IgnoreProperty<SharedDocumentDTO>(f => f.Token);
|
|
this.Verifier.Settings.IgnoreProperty<SharedDocumentByTokenDTO>(f => f.GeneratedDocument);
|
|
this.Verifier.Settings.IgnoreProperty<SharedDocumentByTokenDTO>(f => f.SharedDocument.DocumentData);
|
|
this.Verifier.Settings.IgnoreProperty<SharedDocumentDTO>(f => f.DocumentData);
|
|
}
|
|
|
|
private const int Offer1I3D = 6713;
|
|
private const int Offer2I3D= 5554;
|
|
private const int Offer3I3D= 6750;
|
|
|
|
private const int Offer2ItemI3D1 = 15134;
|
|
private const int Offer2ItemI3D2 = 15137;
|
|
|
|
public override void Execute()
|
|
{
|
|
this.PrepareDatabase();
|
|
|
|
this.ChangeWebReceiptSettings(allowAcceptReceipt:true, allowChangeQuantity:true);
|
|
|
|
var token1 = this.GenerateWebOffer(Offer1I3D);
|
|
this.TryChangeAddresses(step: 1, token1);
|
|
this.TryChangeAddresses(step: 2, token1); // Try it again, it should re-use the same address as before, and not create a new one
|
|
|
|
TestMails.Start(() =>
|
|
{
|
|
this.TryChangePurchaseOrderNumber(step: 3, token1);
|
|
|
|
this.TryChangeWebReceiptState(step: 4, token1, WebReceiptState.AcceptFullWebReceipt);
|
|
|
|
var token2 = this.GenerateWebOffer(Offer2I3D);
|
|
this.GenerateWebReceiptItemRequets(token2);
|
|
this.TryChangeWebReceiptState(step:5, token2, WebReceiptState.AcceptWebReceiptWithChangeRequests);
|
|
|
|
this.ChangeWebReceiptSettings(allowAcceptReceipt:true, allowAcceptReceiptWithoutSignature: true);
|
|
var token3 = this.GenerateWebOffer(Offer3I3D);
|
|
this.TryChangeWebReceiptState(step:6, token3, WebReceiptState.AcceptFullWebReceipt, loadSharedDocument:false);
|
|
});
|
|
|
|
}
|
|
|
|
private void PrepareDatabase()
|
|
{
|
|
var settings = this.WithSession(f => f.GetBL<CentronNexusBL>().GetCentronNexusSettings());
|
|
settings.CentronNexusUrl = "https://test.de/nexus";
|
|
this.WithSession(f => f.GetBL<CentronNexusBL>().UpdateCentronNexusSettings(settings));
|
|
|
|
var signatureDocumentI3D = this.GetSignatureDocument("Deckblatt - Ausleitung.docx");
|
|
|
|
var sharedDocumentSettings = this.WithSession(f => f.GetBL<AppSettingsGroupBL>().GetSharedDocumentSettings());
|
|
|
|
sharedDocumentSettings.OfferSignaturePartI3D = signatureDocumentI3D;
|
|
|
|
this.WithSession(f => f.GetBL<AppSettingsGroupBL>().UpdateSharedDocumentSettings(sharedDocumentSettings));
|
|
|
|
var mailSettings = this.WithSession(f => f.GetBL<MailSettingsBL>().GetMailSettings());
|
|
mailSettings.SmtpHost = "localhost";
|
|
mailSettings.SmtpPort = 25;
|
|
mailSettings.WebserviceMailClient = CentronWebserviceMailType.SMTP;
|
|
mailSettings.SignatureMailSender = "Peter@c-entron.de";
|
|
this.WithSession(f => f.GetBL<MailSettingsBL>().SetMailSettings(mailSettings, this.GetLoggedInUser()));
|
|
|
|
Sql($@"
|
|
UPDATE ARTIK SET isMietPortal = 0 WHERE isMietPortal IS NULL
|
|
UPDATE ARTIK SET Maintenance = 0 WHERE Maintenance IS NULL
|
|
UPDATE ARTIK SET IsServiceArticle = 0 WHERE IsServiceArticle IS NULL
|
|
UPDATE ARTIK SET Fertigungsware = 0 WHERE Fertigungsware IS NULL
|
|
|
|
UPDATE ReportDataQueries SET Statement = 'SELECT Bild1 FROM Artikelbilder' WHERE I3D = 102
|
|
");
|
|
}
|
|
|
|
private string GenerateWebOffer(int offerI3D)
|
|
{
|
|
var pdfDocument = this.WithSession(f => f
|
|
.GetBL<ReceiptCommentWebServiceBL>()
|
|
.SaveReceiptPdfDocumentForReceipt(offerI3D, CentronObjectKindNumeric.OfferClass, this.GetLoggedInUser())).ThrowIfError();
|
|
|
|
return pdfDocument.ReceiptPdfDocument.ReceiptAccessToken;
|
|
}
|
|
|
|
private void TryChangeAddresses(int step, string token)
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var receiverText = session.GetBL<ReceiptWebServiceBL>().ChangeWebReceiptAddress(
|
|
token,
|
|
ReceiptAddressKind.DeliveryAddress,
|
|
"12345",
|
|
"Musterstadt",
|
|
"Musterstraße 12",
|
|
"Baba-Abteilung",
|
|
1,
|
|
1,
|
|
"Maxi",
|
|
"Mustermann",
|
|
"Muster@duster.de");
|
|
|
|
this.Verifier.Verify($"{step}_CreatedReceiverText", receiverText);
|
|
this.Verifier.VerifySql($"{step}_OfferDeliveryAddress", $"SELECT Version, DeliveryAddress, DeliveryAddressCustomerI3D, DeliveryAddressAddressI3D, DeliveryAddressContactPersonI3D FROM dbo.Offers WHERE I3D = {Offer1I3D}");
|
|
}
|
|
|
|
private void TryChangePurchaseOrderNumber(int step, string token)
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
session.GetBL<ReceiptWebServiceBL>().ChangeWebReceiptPurchaseOrderNumber(token, "Neue Bestellnummer");
|
|
|
|
this.Verifier.VerifySql($"{step}_PurchaseOrderNumber", $"SELECT Version, PurchaseOrderNumber FROM dbo.Offers WHERE I3D = {Offer1I3D}");
|
|
}
|
|
|
|
private void TryChangeWebReceiptState(int step, string token, WebReceiptState webReceiptState, bool loadSharedDocument = true)
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var tokenResult = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().ChangeWebReceiptState(token, webReceiptState));
|
|
|
|
if (loadSharedDocument)
|
|
{
|
|
var sharedDocument = this.WithSession(f => f.GetBL<SharedDocumentWebServiceBL>().GetSharedDocumentByToken(tokenResult.Token));
|
|
this.Verifier.Verify($"{step}ChangeWebReceiptState_{webReceiptState}", sharedDocument);
|
|
Assert.NotNull(sharedDocument.Data.GeneratedDocument);
|
|
Assert.NotEmpty(sharedDocument.Data.GeneratedDocument);
|
|
}
|
|
else
|
|
{
|
|
this.Verifier.Verify($"{step}ChangeWebReceiptState_TokenResult_{webReceiptState}", tokenResult);
|
|
}
|
|
}
|
|
|
|
private void GenerateWebReceiptItemRequets(string token)
|
|
{
|
|
this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().RequestForWebReceiptItemChange(token, Offer2ItemI3D1, ChangeRequestKind.QuantityChange, 5, null));
|
|
this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().RequestForWebReceiptItemChange(token, Offer2ItemI3D2, ChangeRequestKind.QuantityChange, 10, null));
|
|
}
|
|
|
|
private void ChangeWebReceiptSettings(bool allowAcceptReceipt = false, bool allowAcceptReceiptWithoutSignature = false, bool allowChangeQuantity = false, bool allowChangeReceiptItemArticlePositionKind = false)
|
|
{
|
|
var loadedSettings = this.WithSession(f => f.GetBL<EmployeeUserSettingsWebServiceBL>().GetEmployeeWebReceiptSetting(this.GetLoggedInUser())).ThrowIfError();
|
|
loadedSettings.AllowAcceptReceipt = allowAcceptReceipt;
|
|
loadedSettings.AllowAcceptReceiptWithoutSignature = allowAcceptReceiptWithoutSignature;
|
|
loadedSettings.AllowChangeQuantity = allowChangeQuantity;
|
|
loadedSettings.AllowChangeReceiptItemArticlePositionKind = allowChangeReceiptItemArticlePositionKind;
|
|
|
|
this.WithSession(f => f.GetBL<EmployeeUserSettingsWebServiceBL>().SaveEmployeeWebReceiptSetting(this.GetLoggedInUser(), loadedSettings));
|
|
|
|
}
|
|
|
|
|
|
private int GetSignatureDocument(string name)
|
|
{
|
|
using var stream = this.GetType().Assembly.GetManifestResourceStream(this.GetType(), name);
|
|
using var memoryStream = new MemoryStream();
|
|
|
|
stream.CopyTo(memoryStream);
|
|
|
|
var directory = this.WithSession(f => f.GetBL<DirectoryReferenceWebServiceBL>().GetDirectoryReference(this.GetLoggedInUser(), 0, CentronObjectKindNumeric.Unknown, DirectoryReferenceKind.TextsDirI3D)).ThrowIfError();
|
|
|
|
return this.WithSession(f => f.GetBL<DocumentWebServiceBL>().AddDocumentToDirectory(this.GetLoggedInUser(),
|
|
directory.I3D,
|
|
memoryStream.ToArray(),
|
|
name)).I3D;
|
|
}
|
|
} |