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
289 lines
11 KiB
C#
289 lines
11 KiB
C#
|
|
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.WebServices.Administration.FileManagement;
|
|
using Centron.Data.WebServices.Administration.FileManagement;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.Administration.Documents;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
using Centron.Core.Extensions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.Documents
|
|
{
|
|
public class DocumentsTests : EndToEndTest
|
|
{
|
|
private int _referenceDirectoryI3D => 2093;
|
|
private int _referenceReceiptI3D => 242;
|
|
private int _referenceDocumentI3D;
|
|
private int _referenceDocument2I3D;
|
|
|
|
public DocumentsTests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
// need to be ignored so we don't get an actual version from the assembly which is always different
|
|
this.Verifier.Settings.IgnoreProperty<DocumentDTO>(f => f.ChangedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<DocumentDTO>(f => f.CreatedVersion);
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
// there are no documents in the testDB at all, so we first have to create them
|
|
// so we have to be careful with our order of operations: create->work with it->delete
|
|
|
|
this.AddDocumentToDirectory();
|
|
this.AddDocumentWithInvalidName();
|
|
this.AddDocumentToSpecialDirectory();
|
|
|
|
this.GetDocumentsByDirectory(1);
|
|
this.GetDocumentMetaInformations();
|
|
|
|
this.GetDocument();
|
|
|
|
this.UpdateFlags();
|
|
this.RenameDocument();
|
|
|
|
this.NewDocumentVersion();
|
|
this.CheckOutDocument();
|
|
this.CheckInDocument();
|
|
this.UndoCheckOutDocument();
|
|
|
|
this.DeleteDocument();
|
|
|
|
// rerun documentsbydirectory to ensure that we have the correct documents after everything we did
|
|
this.GetDocumentsByDirectory(2);
|
|
}
|
|
|
|
private void AddDocumentToDirectory()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var result = session.GetBL<DocumentWebServiceBL>().AddDocumentToDirectory(this.GetLoggedInUser(),
|
|
this._referenceDirectoryI3D,
|
|
new byte[]
|
|
{
|
|
1,2,3,4,5,6,7,8,10,11,12,13,14,15
|
|
},
|
|
"ibims1bildchen",
|
|
new List<DocumentMetaInformationDTO>
|
|
{
|
|
new DocumentMetaInformationDTO
|
|
{
|
|
Type = DocumentMetaInformationType.ReceiptNumber,
|
|
TypeName = "ibims1receiptnumber",
|
|
Value = "123"
|
|
},
|
|
new DocumentMetaInformationDTO
|
|
{
|
|
Type = DocumentMetaInformationType.SupplierI3D,
|
|
TypeName = "ibims1supplieri3d",
|
|
Value = "123"
|
|
}
|
|
}, fileObjectKind:CentronObjectKindNumeric.Chat);
|
|
|
|
this._referenceDocumentI3D = result.I3D;
|
|
}
|
|
}
|
|
|
|
private void AddDocumentWithInvalidName()
|
|
{
|
|
// this is specifically to test handling of Centron.Core.StringExtensions.ConvertToAscii()
|
|
|
|
var asciiConvertedStrings = new List<string>()
|
|
{
|
|
"üöua",
|
|
"?.!bkalsdfjÄÖÜ",
|
|
"japaneseこんにちはsentence" // this is wild
|
|
}.Select(f => f.ConvertToAscii()).ToList();
|
|
this.Verifier.Verify("AsciiConvertedStrings", asciiConvertedStrings);
|
|
|
|
int documentI3D;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
documentI3D = session.GetBL<DocumentWebServiceBL>().AddDocumentToDirectory(this.GetLoggedInUser(),
|
|
this._referenceDirectoryI3D,
|
|
new byte[]
|
|
{
|
|
1,2,3,4,5,6,7,8,10,11,12,13,14,15
|
|
},
|
|
"yeshälloümööf").I3D;
|
|
}
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var resultDocument = session.GetBL<DocumentWebServiceBL>().GetDocument(this.GetLoggedInUser(), documentI3D).Data;
|
|
|
|
this.Verifier.Verify("DocumentWithAdjustedName", resultDocument);
|
|
}
|
|
}
|
|
|
|
private void AddDocumentToSpecialDirectory()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
// this writes the document into the same directory as the AddDocumentToDirectory() does, just via a different method
|
|
var result = session.GetBL<DocumentWebServiceBL>().AddDocumentToSpecialDirectory(this.GetLoggedInUser(),
|
|
"ibims2bildchen",
|
|
new byte[]
|
|
{
|
|
1,2,3,4,5,6,7,8,10,11,12,13,14,15
|
|
},
|
|
this._referenceReceiptI3D,
|
|
CentronObjectKindNumeric.OrderClass,
|
|
new List<DocumentMetaInformationDTO>
|
|
{
|
|
new DocumentMetaInformationDTO
|
|
{
|
|
Type = DocumentMetaInformationType.ReceiptNumber,
|
|
TypeName = "ibims2receiptnumber",
|
|
Value = "456"
|
|
},
|
|
new DocumentMetaInformationDTO
|
|
{
|
|
Type = DocumentMetaInformationType.SupplierI3D,
|
|
TypeName = "ibims2supplieri3d",
|
|
Value = "456"
|
|
}
|
|
});
|
|
|
|
this._referenceDocument2I3D = result.I3D;
|
|
}
|
|
}
|
|
|
|
private void GetDocumentsByDirectory(int version)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var documents = session.GetBL<DocumentWebServiceBL>().GetDocumentsFromDirectory(this.GetLoggedInUser(), this._referenceDirectoryI3D);
|
|
|
|
this.Verifier.Verify("DocumentsFromDirectory" + version, documents);
|
|
}
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var documents = session.GetBL<DocumentWebServiceBL>().GetDocumentsByDirectory(this._referenceDirectoryI3D);
|
|
|
|
this.Verifier.Verify("DocumentsByDirectory" + version, documents);
|
|
}
|
|
}
|
|
private void GetDocumentMetaInformations()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var metaInformations = session.GetBL<DocumentWebServiceBL>().GetDocumentMetaInformations(this.GetLoggedInUser(), new List<int>()
|
|
{
|
|
this._referenceDocumentI3D,
|
|
this._referenceDocument2I3D
|
|
});
|
|
|
|
this.Verifier.Verify("MetaInformations", metaInformations);
|
|
}
|
|
}
|
|
|
|
private void GetDocument()
|
|
{
|
|
var document = this.GetReferenceDocument();
|
|
this.Verifier.Verify("Document", document);
|
|
}
|
|
|
|
private void UpdateFlags()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().UpdateDocumentFlags(this.GetLoggedInUser(), this._referenceDocumentI3D, DocumentFlags.IsPrinted | DocumentFlags.Checked);
|
|
}
|
|
|
|
var document = this.GetReferenceDocument();
|
|
this.Verifier.Verify("NewDocumentFlags", document.Flags);
|
|
}
|
|
private void RenameDocument()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().RenameDocument(this.GetLoggedInUser(), this._referenceDocumentI3D, "ibims1document");
|
|
}
|
|
|
|
var document = this.GetReferenceDocument();
|
|
this.Verifier.Verify("NewDocumentName", document.Name);
|
|
}
|
|
|
|
private void NewDocumentVersion()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().AddNewDocumentVersion(this._referenceDocumentI3D, new byte[]
|
|
{
|
|
1,2,3,4,5,6,7,8,10
|
|
}, this.GetLoggedInUser());
|
|
}
|
|
|
|
var document = this.GetReferenceDocument();
|
|
this.Verifier.Verify("NewDocumentVersion", document);
|
|
|
|
// we override this here as CheckInDocument creates a new version of the document, and we want to work with the newest version
|
|
this._referenceDocumentI3D = document.I3D;
|
|
}
|
|
private void CheckOutDocument()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().CheckOutDocument(this._referenceDocumentI3D, "ibims1workstation", "ibims1dateipfad", this.GetLoggedInUser());
|
|
}
|
|
|
|
var document = this.GetReferenceDocument();
|
|
this.Verifier.Verify("DocumentCheckedOut", document);
|
|
}
|
|
private void CheckInDocument()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().CheckInDocument(this._referenceDocumentI3D, new byte[20], this.GetLoggedInUser());
|
|
}
|
|
|
|
var document = this.GetReferenceDocument();
|
|
this.Verifier.Verify("DocumentCheckedIn", document);
|
|
|
|
// we override this here as CheckInDocument creates a new version of the document, and we want to work with the newest version
|
|
this._referenceDocumentI3D = document.I3D;
|
|
}
|
|
private void UndoCheckOutDocument()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().CheckOutDocument(this._referenceDocumentI3D, "ibims1workstation", "ibims1dateipfad", this.GetLoggedInUser());
|
|
}
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().UndoCheckOut(this._referenceDocumentI3D);
|
|
}
|
|
|
|
var document = this.GetReferenceDocument();
|
|
this.Verifier.Verify("DocumentUndoCheckedOut", document);
|
|
}
|
|
|
|
private void DeleteDocument()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<DocumentWebServiceBL>().DeleteDocument(this.GetLoggedInUser(), this._referenceDocumentI3D);
|
|
}
|
|
|
|
var document = this.GetReferenceDocument();
|
|
Assert.Null(document);
|
|
}
|
|
|
|
private DocumentDTO GetReferenceDocument()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var document = session.GetBL<DocumentWebServiceBL>().GetNewestDocumentVersion(this.GetLoggedInUser(), this._referenceDocumentI3D);
|
|
return document.Data;
|
|
}
|
|
}
|
|
}
|
|
}
|