Skip to content

Commit

Permalink
Merge pull request ppy#13 from smoogipoo/fix-interpolation-test
Browse files Browse the repository at this point in the history
Fix interpolated string tests
  • Loading branch information
smoogipoo authored May 21, 2021
2 parents c46acc5 + 55de3f5 commit a6b955a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class LocaliseClassStringCodeFixTests : AbstractLocaliseStringCodeFixTest
[Theory]
[InlineData("BasicString")]
[InlineData("VerbatimString")]
[InlineData("InterpolatedString")]
[InlineData("InterpolatedStringWithQuotes")]
public async Task Check(string name) => await RunTest(name);

protected override Task Verify((string filename, string content)[] sources, (string filename, string content)[] fixedSources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace TestProject.Localisation
{
public static class ProgramStrings
{
private const string prefix = @"TestProject.Localisation.ProgramStrings";
private const string prefix = @"TestProject.Localisation.Program";

/// <summary>
/// "this is an interpolated string (i = {0})""
/// "this is an interpolated string (i = {0})"
/// </summary>
public static LocalisableString Thisisanin(int i) => new TranslatableString(getKey(@"thisisanin"), @"this is an interpolated string (i = {0})", i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace Test
{
static void Main()
{
string x = ProgramStrings.Thisisanin;
int i = 5;
string x = ProgramStrings.Thisisanin(i);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Localisation;

namespace TestProject.Localisation
{
public static class ProgramStrings
{
private const string prefix = @"TestProject.Localisation.Program";

/// <summary>
/// "Folder "{0}" not available in the target osu!stable installation to import."
/// </summary>
public static LocalisableString Foldernota(string fullPath) => new TranslatableString(getKey(@"foldernota"), @"Folder ""{0}"" not available in the target osu!stable installation to import.", fullPath);

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using TestProject.Localisation;

namespace Test
{
class Program
{
static void Main()
{
string fullPath = string.Empty;
string x = ProgramStrings.Foldernota(fullPath);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Test
{
class Program
{
static void Main()
{
string fullPath = string.Empty;
string x = [|$"Folder \"{fullPath}\" not available in the target osu!stable installation to import."|];
}
}
}

0 comments on commit a6b955a

Please sign in to comment.