Utils: Add SplitAddress and SplitName

This commit is contained in:
2023-09-07 00:39:45 +02:00
parent 7086a72fab
commit 1c45e95ef3
2 changed files with 61 additions and 0 deletions

View File

@ -68,5 +68,37 @@ namespace Tests {
Assert.Throws<ArgumentException>(() => Utils.Modulo("789", -1));
});
}
[Test]
public void Test_SplitAddress() {
Assert.Multiple(() => {
Assert.That(Utils.SplitAddress("Winzerstra<72>e 1"), Is.EqualTo(("Winzerstra<72>e", "1")));
Assert.That(Utils.SplitAddress("Auf dem Feld 12"), Is.EqualTo(("Auf dem Feld", "12")));
Assert.That(Utils.SplitAddress("Winzerstra<72>e 5a"), Is.EqualTo(("Winzerstra<72>e", "5a")));
Assert.That(Utils.SplitAddress("Winzerstra<72>e 1-3/2"), Is.EqualTo(("Winzerstra<72>e", "1-3/2")));
Assert.That(Utils.SplitAddress("Winzerstra<72>e 3/4/5"), Is.EqualTo(("Winzerstra<72>e", "3/4/5")));
Assert.That(Utils.SplitAddress("Winzerstra<72>e 7/2/4/77"), Is.EqualTo(("Winzerstra<72>e", "7/2/4/77")));
Assert.That(Utils.SplitAddress("Winzerstra<72>e 95b"), Is.EqualTo(("Winzerstra<72>e", "95b")));
Assert.That(Utils.SplitAddress("Winzerstra<72>e 1, TOP 3"), Is.EqualTo(("Winzerstra<72>e", "1, TOP 3")));
});
}
[Test]
public void Test_SplitName() {
Assert.Multiple(() => {
Assert.That(Utils.SplitName("Max Bauer", "Bauer"), Is.EqualTo(("Bauer", "Max")));
Assert.That(Utils.SplitName("Bauer Max", "Bauer"), Is.EqualTo(("Bauer", "Max")));
Assert.That(Utils.SplitName("Max und Moritz Bauer", "Bauer"), Is.EqualTo(("Bauer", "Max und Moritz")));
Assert.That(Utils.SplitName("Bauer Max und Moritz", "Bauer"), Is.EqualTo(("Bauer", "Max und Moritz")));
Assert.That(Utils.SplitName("Bauer GesbR", "Bauer"), Is.EqualTo(("Bauer", "GesbR")));
Assert.That(Utils.SplitName("Max und Moritz Bauer GesbR", "Bauer"), Is.EqualTo(("Bauer", "Max und Moritz GesbR")));
Assert.That(Utils.SplitName("Bauer Max und Moritz GesbR", "Bauer"), Is.EqualTo(("Bauer", "Max und Moritz GesbR")));
Assert.That(Utils.SplitName("Weingut Bauer", "Bauer"), Is.EqualTo(("Bauer", "Weingut")));
Assert.That(Utils.SplitName("Bauer Weingut", "Bauer"), Is.EqualTo(("Bauer", "Weingut")));
Assert.That(Utils.SplitName("Max und Moritz Bauer und Mustermann", "Bauer"), Is.EqualTo(("Bauer und Mustermann", "Max und Moritz")));
Assert.That(Utils.SplitName("Bauer und Mustermann Max und Moritz", "Bauer"), Is.EqualTo(("Bauer und Mustermann", "Max und Moritz")));
Assert.That(Utils.SplitName("ABC GesbR", "Bauer"), Is.EqualTo(((string, string?))("ABC GesbR", null)));
});
}
}
}