Upgraded to .NET 10 (#1147)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-01 20:32:16 +01:00
1 parent faae2951f7
commit fc7399e81b
327 files changed
+3059 -3049

No files matched your search

+26 -26
View File
@@ -89,11 +89,11 @@ public sealed class SourcePassageTests
var shown = sources.SelectMany(source => passages.GetPassagesOf(source)).ToList();
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(sources, Has.Count.EqualTo(3), "Three documents, so three sources.");
Assert.That(shown, Is.EquivalentTo(passages), "Each passage shows up under exactly one source.");
});
}
}
[Test]
@@ -103,14 +103,14 @@ public sealed class SourcePassageTests
var twoPages = Passage(HANDBOOK_URL, "Text.", pageNumber: 4, endPageNumber: 5).GetLocationLabel();
var endingWhereItStarts = Passage(HANDBOOK_URL, "Text.", pageNumber: 4, endPageNumber: 4).GetLocationLabel();
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(onePage, Does.Contain("4").And.Not.Contain("5"));
Assert.That(twoPages, Does.Contain("4").And.Contain("5"));
Assert.That(twoPages, Is.Not.EqualTo(onePage));
Assert.That(endingWhereItStarts, Is.EqualTo(onePage), "A passage which ends on the page it starts on is on one page.");
Assert.That(Passage(HANDBOOK_URL, "Text.").GetLocationLabel(), Is.Empty, "A slide or a sheet has no page, and none is invented for it.");
});
}
}
[Test]
@@ -125,12 +125,12 @@ public sealed class SourcePassageTests
Passage(HANDBOOK_URL, "A slide."),
}.GetLocationLabel();
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(label, Does.Contain("1, 4–5, 11"), "Each page once, ranges as ranges, in the order of the document; a passage without a page adds nothing.");
Assert.That(new[] { Passage(HANDBOOK_URL, "A.", pageNumber: 3), Passage(HANDBOOK_URL, "B.", pageNumber: 3) }.GetLocationLabel(), Is.EqualTo(Passage(HANDBOOK_URL, "A.", pageNumber: 3).GetLocationLabel()), "Two passages on one page name one page.");
Assert.That(new[] { Passage(HANDBOOK_URL, "A slide."), Passage(HANDBOOK_URL, "A sheet.") }.GetLocationLabel(), Is.Empty);
});
}
}
[Test]
@@ -140,14 +140,14 @@ public sealed class SourcePassageTests
var location = passages.GetLocation();
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(location, Is.Not.Null);
Assert.That(location!.Ranges, Is.EqualTo(new[] { new LocationRange(1, 2), new LocationRange(11, 11) }), "Each page range becomes a link of its own, in the order of the document.");
Assert.That(location.ArePages, Is.True);
Assert.That(location.ToString(), Is.EqualTo($"{location.Prefix}1–2, 11{location.Suffix}"), "The links read the same as the title of the source.");
Assert.That(new[] { Passage(HANDBOOK_URL, "A slide.") }.GetLocation(), Is.Null, "Where the data source says neither pages nor parts, nothing is invented.");
});
}
}
[Test]
@@ -157,14 +157,14 @@ public sealed class SourcePassageTests
var location = passages.GetLocation();
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(location, Is.Not.Null);
Assert.That(location!.Ranges, Is.EqualTo(new[] { new LocationRange(2, 2), new LocationRange(5, 5) }), "The parts follow the order of the document.");
Assert.That(location.ArePages, Is.False, "A part is nothing a program can open a document at, so it becomes no link.");
Assert.That(location.ToString(), Is.Not.EqualTo(new[] { Passage(MANUAL_URL, "Step two.", pageNumber: 2), Passage(MANUAL_URL, "Step five.", pageNumber: 5) }.GetLocationLabel()), "Parts are not called pages.");
Assert.That(new[] { Passage(MANUAL_URL, "Step two.", pageNumber: 7, chunkNumber: 2) }.GetLocation()!.Ranges, Is.EqualTo(new[] { new LocationRange(7, 7) }), "Where there are pages, they say better where a passage is.");
});
}
}
[Test]
@@ -175,7 +175,7 @@ public sealed class SourcePassageTests
var location = lines.GetLocation();
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(location, Is.Not.Null);
Assert.That(location!.Ranges, Is.EqualTo(new[] { new LocationRange(40, 85), new LocationRange(120, 120) }), "The lines follow the order of the document, and a line range stays a range.");
@@ -184,7 +184,7 @@ public sealed class SourcePassageTests
Assert.That(rows.GetLocationLabel(), Is.Not.EqualTo((rows with { StartRow = null, EndRow = null, StartLine = 12, EndLine = 30 }).GetLocationLabel()), "Rows are not called lines.");
Assert.That((Passage(MANUAL_URL, "Later.", chunkNumber: 120) with { StartLine = 120 }).GetLocationLabel(), Is.Not.EqualTo(Passage(MANUAL_URL, "Later.", chunkNumber: 120).GetLocationLabel()), "Lines are not called parts.");
Assert.That(new[] { lines[1] with { PageNumber = 3 } }.GetLocation()!.ArePages, Is.True, "Where there are pages, they say better where a passage is.");
});
}
}
/// <remarks>
@@ -202,23 +202,23 @@ public sealed class SourcePassageTests
Passage(HANDBOOK_URL, "Rent.", chunkNumber: 1) with { SheetName = "Budget", StartRow = 3, EndRow = 9 },
}.GetLocationLabel();
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(label, Does.Contain("Budget").And.Contain("3–9, 20").And.Contain("Summary"), "Each sheet with its rows, each row once, in the order of the document.");
Assert.That(label.IndexOf("Budget", StringComparison.Ordinal), Is.LessThan(label.IndexOf("Summary", StringComparison.Ordinal)), "The sheets follow the order of the document.");
Assert.That(label.IndexOf("Budget", StringComparison.Ordinal), Is.EqualTo(label.LastIndexOf("Budget", StringComparison.Ordinal)), "A sheet is named once.");
});
}
}
[Test]
public void APassageKnowsItsPlaceInTheDocumentAsNumbers()
{
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(Passage(HANDBOOK_URL, "Method.", pageNumber: 4, endPageNumber: 5).GetLocationRange(), Is.EqualTo(new LocationRange(4, 5)));
Assert.That(Passage(MANUAL_URL, "Step three.", chunkNumber: 3).GetLocationRange(), Is.EqualTo(new LocationRange(3, 3)), "The dialog orders the passages of a text file by their parts.");
Assert.That(Passage(MANUAL_URL, "Somewhere.").GetLocationRange(), Is.Null);
});
}
}
[Test]
@@ -233,13 +233,13 @@ public sealed class SourcePassageTests
SourcePassage[] passages = [Passage($"{HANDBOOK_URL}#page=1", "Introduction.", pageNumber: 1), Passage($"{HANDBOOK_URL}#page=11", "Results.", pageNumber: 11)];
sources.NamePassagesInTitles(passages);
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(sources[0].Title, Is.EqualTo($"Handbooks ({passages.GetLocationLabel()})"), "The page of the second passage would otherwise go unmentioned.");
Assert.That(sources[0].Title, Does.Contain("1, 11"));
Assert.That(sources[0].URL, Is.EqualTo($"{HANDBOOK_URL}#page=1"), "The link still opens the document where the first passage is.");
Assert.That(sources[1].Title, Is.EqualTo("Search result"), "A source without passages keeps its title.");
});
}
}
[Test]
@@ -250,11 +250,11 @@ public sealed class SourcePassageTests
SourcePassage[] passages = [Passage($"{MANUAL_URL}#chunk=1", "Step one.", chunkNumber: 2), Passage($"{MANUAL_URL}#chunk=6", "Step two.", chunkNumber: 7)];
sources.NamePassagesInTitles(passages);
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(sources[0].Title, Is.EqualTo($"Handbooks ({passages.GetLocationLabel()})"), "A title naming one part would hide the other one.");
Assert.That(sources[0].Title, Does.Contain("2, 7"));
});
}
}
[Test]
@@ -267,21 +267,21 @@ public sealed class SourcePassageTests
onePassage.NamePassagesInTitles([Passage("https://wiki.example.org/budget", "Step one.")]);
twoPassages.NamePassagesInTitles([Passage("https://wiki.example.org/budget", "Step one."), Passage("https://wiki.example.org/budget", "Step two.")]);
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(onePassage[0].Title, Is.EqualTo("Wiki"), "One passage keeps the title its data source gave it.");
Assert.That(twoPassages[0].Title, Does.StartWith("Handbooks (").And.Contain("2"), "Two passages under one title are counted, so the user knows to look for both.");
});
}
}
[Test]
public void ATranscriptIsKnownAsSuch()
{
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That((Passage(HANDBOOK_URL, "Welcome.") with { Type = RetrievalContentType.TEXT_TRANSCRIPT }).IsTranscript(), Is.True);
Assert.That(Passage(HANDBOOK_URL, "Welcome.").IsTranscript(), Is.False);
});
}
}
[Test]
@@ -307,7 +307,7 @@ public sealed class SourcePassageTests
using var document = JsonDocument.Parse(json);
var storedPassage = document.RootElement.GetProperty("blocks")[0].GetProperty("content").GetProperty("source_passages")[0];
Assert.Multiple(() =>
using (Assert.EnterMultipleScope())
{
Assert.That(storedPassage.EnumerateObject().Select(property => property.Name), Is.EquivalentTo(new[] { "source_url", "data_source_name", "path", "category", "type", "text", "surrounding_content", "page_number", "end_page_number", "chunk_number" }), "A computed property would end up in every chat file as well.");
Assert.That(storedPassage.GetProperty("type").GetString(), Is.EqualTo("TEXT_DOCUMENT"), "The type is stored by name, so a type added later does not shift the stored ones.");
@@ -318,7 +318,7 @@ public sealed class SourcePassageTests
Assert.That(loadedPassage.SurroundingContent, Is.EqualTo(passage.SurroundingContent));
Assert.That(loadedPassage.PageNumber, Is.EqualTo(3));
Assert.That(loadedPassage.Type, Is.EqualTo(RetrievalContentType.TEXT_DOCUMENT));
});
}
}
[Test]