From e20db6e8e4279dc95371e6f98c0e73dd19020c0f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 28 May 2017 17:34:53 -0400 Subject: add token support for instance fields, expand unit test (#296) --- src/StardewModdingAPI.Tests/TranslationTests.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/StardewModdingAPI.Tests/TranslationTests.cs') diff --git a/src/StardewModdingAPI.Tests/TranslationTests.cs b/src/StardewModdingAPI.Tests/TranslationTests.cs index a2fef2b7..6a430aa7 100644 --- a/src/StardewModdingAPI.Tests/TranslationTests.cs +++ b/src/StardewModdingAPI.Tests/TranslationTests.cs @@ -180,7 +180,7 @@ namespace StardewModdingAPI.Tests ** Translation tokens ****/ [Test(Description = "Assert that multiple translation tokens are replaced correctly regardless of the token structure.")] - public void Translation_Tokens([Values("anonymous object", "IDictionary", "IDictionary")] string structure) + public void Translation_Tokens([Values("anonymous object", "class", "IDictionary", "IDictionary")] string structure) { // arrange string start = Guid.NewGuid().ToString("N"); @@ -197,6 +197,10 @@ namespace StardewModdingAPI.Tests translation = translation.Tokens(new { start, middle, end }); break; + case "class": + translation = translation.Tokens(new TokenModel { Start = start, Middle = middle, End = end }); + break; + case "IDictionary": translation = translation.Tokens(new Dictionary { ["start"] = start, ["middle"] = middle, ["end"] = end }); break; @@ -323,5 +327,22 @@ namespace StardewModdingAPI.Tests { return string.Format(Translation.PlaceholderText, key); } + + + /********* + ** Test models + *********/ + /// A model used to test token support. + private class TokenModel + { + /// A sample token property. + public string Start { get; set; } + + /// A sample token property. + public string Middle { get; set; } + + /// A sample token field. + public string End; + } } } -- cgit