Added the informal address to the BeyondFacts Lab (#1176)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-08 21:10:51 +01:00
1 parent b6c3fbb5db
commit e77645f44c
48 files changed
+1254 -160

No files matched your search

+1 -1
View File
@@ -66,7 +66,7 @@ public sealed class BflAccessTests
{
var forms = ConfigurationSelectDataFactory.GetBeyondFactsLabAddressFormData().Select(data => data.Value);
Assert.That(forms, Is.EquivalentTo(Enum.GetValues<BflAddressForm>()));
Assert.That(forms, Is.EquivalentTo(Enum.GetValues<AddressForm>()));
}
private static SettingsManager CreateSettingsManager() => new(NullLogger<SettingsManager>.Instance, null!);
@@ -0,0 +1,49 @@
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using SharedTools;
namespace AIStudio.Tests.BeyondFactsLab;
/// <summary>
/// Checks that the texts of the BeyondFacts Lab follow the form of address the person chose.
/// </summary>
/// <remarks>
/// A text which says "you" in English addresses the reader in other languages as well, so it needs TA(). With T() or
/// TB(), it would stay formal in German, although the person chose the informal address.
/// </remarks>
[TestFixture]
public sealed partial class BflAddressTests
{
[Test]
public void EveryTextOfTheLabWhichSaysYouFollowsTheFormOfAddress()
{
var texts = 0;
var formalOnly = new List<string>();
foreach (var file in LabSourceFiles())
{
foreach (var text in I18NSourceScanner.FindTexts(File.ReadAllText(file), file, []))
{
texts++;
if (!text.HasAddressVariants && YouRegex().IsMatch(text.Text))
formalOnly.Add($"{Path.GetFileName(file)}: {text.Text}");
}
}
using (Assert.EnterMultipleScope())
{
Assert.That(texts, Is.GreaterThan(80), "The test found too few texts to be looking at the lab.");
Assert.That(formalOnly, Is.Empty);
}
}
[GeneratedRegex(@"\byou(r|rs|rself)?\b", RegexOptions.IgnoreCase)]
private static partial Regex YouRegex();
private static IEnumerable<string> LabSourceFiles([CallerFilePath] string sourceFilePath = "")
{
var appDirectory = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(sourceFilePath)!, "..", "..", "MindWork AI Studio"));
return Directory.EnumerateFiles(Path.Combine(appDirectory, "Assistants", "BeyondFactsLab"))
.Append(Path.Combine(appDirectory, "Dialogs", "Settings", "SettingsDialogBeyondFactsLab.razor"));
}
}
@@ -1,4 +1,3 @@
using AIStudio.Assistants.BeyondFactsLab;
using AIStudio.Provider;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
@@ -142,7 +141,7 @@ public sealed class BflComponentTests
[Test]
public void NewSettingsAddressFormally()
{
Assert.That(new DataBeyondFactsLab().AddressForm, Is.EqualTo(BflAddressForm.FORMAL), "The texts of AI Studio address the person formally as well.");
Assert.That(new DataBeyondFactsLab().AddressForm, Is.EqualTo(AddressForm.FORMAL), "The texts of AI Studio address the person formally as well.");
}
private static SettingsManager CreateSettingsManager() => new(NullLogger<SettingsManager>.Instance, null!);