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

248 lines
9.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Accounts.Survey;
using Centron.BusinessLogic.EmployeeArea;
using Centron.Data.Entities.Administration.Logins;
using Centron.Data.Entities.Services.Workflows;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using CentronSoftware.Centron.WebServices.Entities.Processes;
using CentronSoftware.Centron.WebServices.Entities.Processes.General;
using CentronSoftware.Centron.WebServices.Entities.Processes.Survey;
using CentronSoftware.Centron.WebServices.Entities.Processes.Survey.Steps;
using CentronSoftware.Centron.WebServices.Entities.Processes.Survey.Steps.Instructions;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.Audit
{
public class AuditTest : PerformanceTest
{
private Result<SurveyProcessTemplateDTO> _saveResult;
private SurveyProcessTemplateDTO _loadedTemplate;
protected override TimeSpan? AllowedDuration => TimeSpan.FromMilliseconds(300);
private LoggedInUser GetUser()
{
using (var session = new BLSession())
return new LoggedInUser(session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11));
}
public AuditTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
protected override void Prepare()
{
this.CreateAuditTemplate();
this.LoadAudit();
}
protected override void Measure()
{
this.SaveSurveyForCustomer();
}
private void CreateAuditTemplate()
{
var survey = new SurveyProcessTemplateDTO
{
FolderI3D = 1,
Name = "AuditForEndToEndTest",
Steps = new List<ProcessStepDTO>
{
new StartProcessStepDTO
{
I3D = 0,
BindingGuid = Guid.Parse("683c20d0-f494-4b23-8c9b-478538471cdf"),
Description = null,
IsCurrent = true,
Kind = WorkflowShapeKind.GeneralStart,
LocationX = 500,
LocationY = 500,
Name = "Start"
},
new EndProcessStepDTO
{
I3D = 0,
BindingGuid = Guid.Parse("9468780a-30c7-432e-a71a-85a6a2aaae26"),
Description = null,
IsCurrent = false,
Kind = WorkflowShapeKind.GeneralEnd,
LocationX = 500,
LocationY = 800,
Name = "Ende"
},
new SurveyProcessFreeTextProcessStepDTO
{
I3D = 0,
Answer = null,
BindingGuid = Guid.Parse("e080178f-c777-47ff-8118-73703f3c80cc"),
Category = 0,
Comment = null,
Description = null,
Instructions = new List<SurveyProcessStepInstructionDTO>(),
IsCurrent = false,
Kind = WorkflowShapeKind.SurveyProcessFreeText,
LocationX = 303.62901737943247,
LocationY = 567.62104719383046,
Name = "Freitext"
},
new SurveyProcessMultiChoiceProcessStepDTO
{
I3D = 0,
BindingGuid = Guid.Parse("0dd56c6a-6534-4510-ad6d-f3b3de309feb"),
Category = 0,
Choices = new List<string>(),
Comment = null,
Description = null,
GenerateConnectionsForEachChoice = false,
Instructions = new List<SurveyProcessStepInstructionDTO>(),
IsCurrent = false,
Kind = WorkflowShapeKind.SurveyProcessMultiChoice,
LocationX = 570.17637725545183,
LocationY = 636.64433046751037,
MutliSelect = false,
Name = "Multiple choice"
},
},
Properties = new SurveyProcessPropertiesDTO
{
I3D = 2,
ContactI3D = 0,
ContactPersonI3D = 0,
EMail = null,
FirstLoadOnWEB = null,
IsCopy = false,
IsTemplate = false,
ObjectI3D = null,
ObjectKind = null,
ReleaseDate = null,
ReleasedFromI3D = 0,
RespondentName = null,
Status = SurveyStatus.InProcess,
SurveyI3D = 0,
TemplateI3D = 0
},
Bindings = new List<ProcessBindingDTO>
{
new ProcessBindingDTO
{
I3D = 0,
Caption = null,
ConnectorType = BindingConnectorType.Straight,
FromStep = Guid.Parse("683c20d0-f494-4b23-8c9b-478538471cdf"),
Kind = BindingKind.Default,
ToStep = Guid.Parse("e080178f-c777-47ff-8118-73703f3c80cc")
},
new ProcessBindingDTO
{
I3D = 0,
Caption = null,
ConnectorType = BindingConnectorType.Straight,
FromStep = Guid.Parse("e080178f-c777-47ff-8118-73703f3c80cc"),
Kind = BindingKind.Default,
ToStep = Guid.Parse("0dd56c6a-6534-4510-ad6d-f3b3de309feb")
},
new ProcessBindingDTO
{
I3D = 0,
Caption = null,
ConnectorType = BindingConnectorType.Straight,
FromStep = Guid.Parse("0dd56c6a-6534-4510-ad6d-f3b3de309feb"),
Kind = BindingKind.Default,
ToStep = Guid.Parse("9468780a-30c7-432e-a71a-85a6a2aaae26")
}
}
};
using (var session = new BLSession())
{
var result = session.GetBL<SurveyProcessBL>().SaveSurvey(survey, this.GetUser().User);
Assert.Equal(ResultStatus.Success, result.Status);
Assert.NotNull(result.Data);
this.Verifier.Verify("AuditTemplateTest", result.Data);
}
}
private void LoadAudit()
{
using (var session = new BLSession())
{
this._loadedTemplate = session.GetBL<SurveyProcessBL>().GetSurveyByI3D(3);
Assert.NotNull(_loadedTemplate);
this.Verifier.Verify("GetAuditTemplateTest", this._loadedTemplate);
}
}
private void SaveSurveyForCustomer()
{
using (var session = new BLSession())
{
var newtemplate = new SurveyProcessTemplateDTO
{
FolderI3D = null,
I3D = 0,
Properties = this._loadedTemplate.Properties,
Steps = this.ReseteAllAnswer(this._loadedTemplate.Steps),
Bindings = this._loadedTemplate.Bindings,
Name = this._loadedTemplate.Name
};
newtemplate.Properties.SurveyI3D = 0;
newtemplate.Properties.I3D = 0;
newtemplate.Properties.IsCopy = true;
newtemplate.Properties.TemplateI3D = this._loadedTemplate.I3D;
newtemplate.Properties.Status = SurveyStatus.Open;
newtemplate.Properties.ReleaseDate = DateTime.Now;
newtemplate.Properties.ReleasedFromI3D = this.GetUser().User.Employee.I3D;
newtemplate.Properties.EMail = "bortoli@c-entron.de";
newtemplate.Properties.ContactPersonI3D = 1;
newtemplate.Properties.ContactI3D = 1;
newtemplate.Properties.RespondentName = "Andreas Bortoli";
this._saveResult = session.GetBL<SurveyProcessBL>().SaveSurvey(newtemplate, this.GetUser().User);
}
}
protected override void AssertResults()
{
Assert.NotNull(this._saveResult);
Assert.Equal(ResultStatus.Success, this._saveResult.Status);
Assert.NotNull(this._saveResult.Data);
this.Verifier.Verify("SaveAuditForContactTest", this._saveResult.Data);
}
public List<ProcessStepDTO> ReseteAllAnswer(List<ProcessStepDTO> steplist)
{
foreach (var step in steplist)
{
if (step is SurveyProcessFreeTextProcessStepDTO freeText)
freeText.Answer = string.Empty;
if (step is SurveyProcessMultiChoiceProcessStepDTO multi)
multi.SelectedIndexes = new List<int>();
if (step is SurveyProcessYesNoProcessStepDTO yesno)
yesno.Answer = null;
if (step is SurveyProcessScaleProcessStepDTO scale)
scale.Answer = scale.Min;
}
return steplist;
}
}
}