Files
Masterarbeit/QuellCode/CentronERP/tests/shared/Centron.Tests.Controls/PositionGrid/PasteIndentNormalizerTests.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

140 lines
4.4 KiB
C#

using CentronSoftware.Centron.Controls.PositionGrid.Helpers;
using CentronSoftware.Centron.Controls.PositionGrid.Interfaces;
namespace Centron.Tests.Controls.PositionGrid
{
/// <summary>
/// Tests for the indent normalization of a cut-out of positions that is pasted into the receipt
/// </summary>
public class PasteIndentNormalizerTests
{
private static (ReceiptArticleKind kind, bool? isExpanded, int indent) Position(int indent)
=> (ReceiptArticleKind.Article, null, indent);
private static (ReceiptArticleKind kind, bool? isExpanded, int indent) PartListHead(int indent)
=> (ReceiptArticleKind.Article, true, indent);
private static (ReceiptArticleKind kind, bool? isExpanded, int indent) Title(int indent)
=> (ReceiptArticleKind.Titleposition, true, indent);
[Fact]
public void CalculateIndents_TitleIndentDoesNotAffectFollowingPartList()
{
// A title with a non-zero source indent must not stay the indent reference for the
// positions after it, otherwise the following part-list head pushes currentIndent below
// zero and its child ends up at indent 0 instead of 1.
var positions = new[]
{
Title(2),
PartListHead(0),
Position(1),
};
var indents = PasteIndentNormalizer.CalculateIndents(positions);
Assert.Equal(new[] { 0, 0, 1 }, indents);
}
[Fact]
public void CalculateIndents_TitleResetsIndentOfPrecedingPartList()
{
var positions = new[]
{
PartListHead(0),
Position(1),
Title(0),
Position(0),
};
var indents = PasteIndentNormalizer.CalculateIndents(positions);
Assert.Equal(new[] { 0, 1, 0, 0 }, indents);
}
[Fact]
public void CalculateIndents_RebasesCutOutTakenFromInsideAPartList()
{
// Cut-out starts at indent 2 because it was copied out of a nested part-list.
var positions = new[]
{
PartListHead(2),
Position(3),
Position(3),
Position(2),
};
var indents = PasteIndentNormalizer.CalculateIndents(positions);
Assert.Equal(new[] { 0, 1, 1, 0 }, indents);
}
[Fact]
public void CalculateIndents_KeepsNestedPartLists()
{
var positions = new[]
{
PartListHead(0),
PartListHead(1),
Position(2),
Position(1),
};
var indents = PasteIndentNormalizer.CalculateIndents(positions);
Assert.Equal(new[] { 0, 1, 2, 1 }, indents);
}
[Fact]
public void CalculateIndents_ClosesAllPartListsLeftAtOnce()
{
// The last position leaves three part-lists at the same time and therefore belongs back
// on the top level.
var positions = new[]
{
PartListHead(0),
PartListHead(1),
PartListHead(2),
Position(0),
};
var indents = PasteIndentNormalizer.CalculateIndents(positions);
Assert.Equal(new[] { 0, 1, 2, 0 }, indents);
}
[Fact]
public void CalculateIndents_ClosesPartListsUpToTheRemainingLevel()
{
// The cut-out drops from indent 3 back to indent 1, so only the two inner part-lists are
// closed and the position stays inside the outermost one.
var positions = new[]
{
PartListHead(0),
PartListHead(1),
PartListHead(2),
Position(3),
Position(1),
};
var indents = PasteIndentNormalizer.CalculateIndents(positions);
Assert.Equal(new[] { 0, 1, 2, 3, 1 }, indents);
}
[Fact]
public void CalculateIndents_FlatPositionsStayAtZero()
{
var positions = new[]
{
Position(0),
Position(0),
Position(0),
};
var indents = PasteIndentNormalizer.CalculateIndents(positions);
Assert.Equal(new[] { 0, 0, 0 }, indents);
}
}
}