Skip to content

Commit c1781c2

Browse files
committed
U4-2635 add failing test
Only first occurrence of oldString is replaced.
1 parent b60aa30 commit c1781c2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Umbraco.Tests/CoreStrings/StringExtensionsTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ public void TrimStart(string input, string forTrimming, string shouldBe)
8080
Assert.AreEqual(shouldBe, trimmed);
8181
}
8282

83+
[TestCase("Hello this is my string", "hello", "replaced", "replaced this is my string", StringComparison.CurrentCultureIgnoreCase)]
84+
[TestCase("Hello this is hello my string", "hello", "replaced", "replaced this is replaced my string", StringComparison.CurrentCultureIgnoreCase)]
85+
[TestCase("Hello this is my string", "nonexistent", "replaced", "Hello this is my string", StringComparison.CurrentCultureIgnoreCase)]
86+
public void ReplaceWithStringComparison(string input, string oldString, string newString, string shouldBe, StringComparison stringComparison)
87+
{
88+
var replaced = input.Replace(oldString, newString, stringComparison);
89+
Assert.AreEqual(shouldBe, replaced);
90+
}
91+
8392
[TestCase(null, null)]
8493
[TestCase("", "")]
8594
[TestCase("x", "X")]

0 commit comments

Comments
 (0)