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
178 lines
6.4 KiB
C#
178 lines
6.4 KiB
C#
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.WebServices.Mail.Templates;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.Mail.Templates;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using CentronSoftware.Centron.WebServices.Entities.Administration.FileManagement;
|
|
using CentronSoftware.Centron.WebServices.Entities.Mail.Templates;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.MailTemplateAttachments
|
|
{
|
|
public class MailTemplateAttachmentsTest : EndToEndTest
|
|
{
|
|
public MailTemplateAttachmentsTest(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
private byte[] _file = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
|
|
|
|
public override void Execute()
|
|
{
|
|
this.SaveMailTemplateAttachment();
|
|
this.SaveMailTemplateAttachments();
|
|
this.GetMailTemplateAttachments();
|
|
this.UpdateMailTemplateAttachment();
|
|
this.GetGlobalMailTemplateAttachments();
|
|
this.DeleteMailTemplateAttachments();
|
|
}
|
|
|
|
private void SaveMailTemplateAttachment()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var loggedInUser = this.GetLoggedInUser();
|
|
|
|
var attachment = session.GetBL<MailTemplateWebServiceBL>().SaveMailTemplateAttachment(
|
|
new MailTemplateAttachmentDTO
|
|
{
|
|
ObjectKind = CentronObjectKindNumeric.PLM,
|
|
SubObjectKind = null,
|
|
ObjectI3D = 1,
|
|
Name = "Test.png",
|
|
FileType = DocumentType.PDF,
|
|
FileData = _file,
|
|
FileSize = _file.Length,
|
|
BranchI3D = null,
|
|
AccountI3D = null,
|
|
CreatedAt = DateTime.Now,
|
|
CreatedByI3D = loggedInUser.User.Employee.I3D,
|
|
},
|
|
this.GetLoggedInUser()).Data;
|
|
|
|
Assert.NotNull(attachment);
|
|
}
|
|
|
|
private void SaveMailTemplateAttachments()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var loggedInUser = this.GetLoggedInUser();
|
|
|
|
session.GetBL<MailTemplateWebServiceBL>().SaveAllMailtemplateAttachments(
|
|
new List<MailTemplateAttachmentDTO>
|
|
{
|
|
new MailTemplateAttachmentDTO
|
|
{
|
|
ObjectKind = CentronObjectKindNumeric.PLM,
|
|
SubObjectKind = null,
|
|
ObjectI3D = 1,
|
|
Name = "Test.png",
|
|
FileType = DocumentType.PDF,
|
|
FileData = _file,
|
|
FileSize = _file.Length,
|
|
BranchI3D = null,
|
|
AccountI3D = null,
|
|
CreatedAt = DateTime.Now,
|
|
CreatedByI3D = loggedInUser.User.Employee.I3D,
|
|
},
|
|
new MailTemplateAttachmentDTO
|
|
{
|
|
ObjectKind = CentronObjectKindNumeric.PLM,
|
|
SubObjectKind = null,
|
|
ObjectI3D = 2,
|
|
Name = "Test1.png",
|
|
FileType = DocumentType.PDF,
|
|
FileData = _file,
|
|
FileSize = _file.Length,
|
|
BranchI3D = null,
|
|
AccountI3D = null,
|
|
CreatedAt = DateTime.Now,
|
|
CreatedByI3D = loggedInUser.User.Employee.I3D,
|
|
},
|
|
new MailTemplateAttachmentDTO
|
|
{
|
|
ObjectKind = CentronObjectKindNumeric.PLM,
|
|
SubObjectKind = null,
|
|
ObjectI3D = 1,
|
|
Name = "Test2.png",
|
|
FileType = DocumentType.PDF,
|
|
FileData = _file,
|
|
FileSize = _file.Length,
|
|
BranchI3D = null,
|
|
AccountI3D = null,
|
|
CreatedAt = DateTime.Now,
|
|
CreatedByI3D = loggedInUser.User.Employee.I3D,
|
|
},
|
|
},
|
|
this.GetLoggedInUser());
|
|
}
|
|
|
|
private void GetMailTemplateAttachments()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var attachments = session.GetBL<MailTemplateWebServiceBL>().GetMailTemplateAttachments(
|
|
this.GetLoggedInUser(),
|
|
objectKind: CentronObjectKindNumeric.PLM,
|
|
subObjectKind: null,
|
|
objectI3D: 1,
|
|
branchI3D: null,
|
|
accountI3D: null,
|
|
customerI3D: null,
|
|
supplierI3D: null,
|
|
employeeI3D: null).Data;
|
|
|
|
Assert.NotEmpty(attachments);
|
|
|
|
this.Verifier.Verify("GetMailTemplateAttachments", attachments);
|
|
}
|
|
|
|
private void UpdateMailTemplateAttachment()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var attachment = session.GetBL<MailTemplateWebServiceBL>().GetMailTemplateAttachment(1).Data;
|
|
|
|
Assert.NotNull(attachment);
|
|
|
|
attachment.IsGlobal = true;
|
|
|
|
var updatedAttachment = session.GetBL<MailTemplateWebServiceBL>().SaveMailTemplateAttachment(attachment, this.GetLoggedInUser());
|
|
|
|
Assert.NotNull(updatedAttachment);
|
|
}
|
|
|
|
private void GetGlobalMailTemplateAttachments()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var attachments = session.GetBL<MailTemplateWebServiceBL>().GetGlobalMailTemplateAttachments().Data;
|
|
|
|
Assert.NotEmpty(attachments);
|
|
}
|
|
|
|
private void DeleteMailTemplateAttachments()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var attachment = session.GetBL<MailTemplateWebServiceBL>().GetMailTemplateAttachment(1).Data;
|
|
|
|
Assert.NotNull(attachment);
|
|
|
|
session.GetBL<MailTemplateWebServiceBL>().DeleteMailTemplateAttachments(new List<MailTemplateAttachmentDTO> { attachment });
|
|
|
|
attachment = session.GetBL<MailTemplateWebServiceBL>().GetMailTemplateAttachment(1).Data;
|
|
|
|
Assert.Null(attachment);
|
|
}
|
|
}
|
|
}
|