Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ygg01 committed Oct 24, 2023
1 parent a081787 commit 9524f98
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
35 changes: 34 additions & 1 deletion Linguini.Bundle.Test/Unit/BundleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ [neuter] It
[Parallelizable]
public void TestMacrosFail()
{
var (bundle, err) = LinguiniBuilder.Builder().Locale("en-US")
var (bundle, err) = LinguiniBuilder.Builder(extension: true).Locale("en-US")
.AddResource(Macros)
.Build();
Assert.IsEmpty(err);
Expand All @@ -325,5 +325,38 @@ public void TestMacrosFail()
Assert.True(bundle.TryGetMessage("call-attr-no-args", args, out _, out var message));
Assert.AreEqual("It", message);
}
private const string DynamicSelectors = @"
-creature-fairy = fairy
-creature-elf = elf
.StartsWith = vowel
you-see = You see { $$object.StartsWith ->
[vowel] an { $$object }
*[consonant] a { $$object }
}.
";

[Test]
[Parallelizable]
public void TestDynamicSelectors()
{
var (bundle, err) = LinguiniBuilder.Builder(extension: true)
.Locale("en-US")
.AddResource(DynamicSelectors)
.Build();
Assert.IsEmpty(err);
var args = new Dictionary<string, IFluentType>
{
["object"] = (FluentReference)"creature-elf",
};
Assert.True(bundle.TryGetMessage("you-see", args, out _, out var message1));
Assert.AreEqual("You see an elf.", message1);
args = new Dictionary<string, IFluentType>
{
["object"] = (FluentReference)"creature-fairy",
};
Assert.True(bundle.TryGetMessage("you-see", args, out _, out var message2));
Assert.AreEqual("You see a fairy.", message2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
tests:
- name: regular reference
asserts:
- id: see-elf
- id: you-see
args:
object: "-creature-elf"
object: "creature-elf"
value: "You see an elf."
- id: see-fairy
- id: you-see
args:
object: "-creature-fairy"
object: "creature-fairy"
value: "You see a fairy."

0 comments on commit 9524f98

Please sign in to comment.