Skip to content

Commit 8c00f80

Browse files
arbitrarybytesVenkatesh
authored andcommitted
Improve code coverage
1 parent d8df5f4 commit 8c00f80

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

src/ArbitraryExtensions.Tests/StringExtensionsTests.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ namespace ArbitraryExtensions.Tests
88
[TestFixture]
99
public class StringExtensionsTests
1010
{
11-
[SetUp]
12-
public void Setup()
13-
{
14-
}
1511

1612
[Test]
1713
[TestCase(null, default(string))]
@@ -20,7 +16,7 @@ public void Setup()
2016
[TestCase(" ", " ")]
2117
public void TestDefaultIfNullOrEmpty(string value, string expect)
2218
{
23-
Assert.AreEqual(expect, StringExtensions.DefaultIfNullOrEmpty(value));
19+
Assert.AreEqual(expect, value.DefaultIfNullOrEmpty());
2420
}
2521

2622
[Test]
@@ -31,7 +27,7 @@ public void TestDefaultIfNullOrEmpty(string value, string expect)
3127
[TestCase(" ", "Default", " ")]
3228
public void TestDefaultIfNullOrEmptyWithDefaultValue(string value, string defaultValue, string expect)
3329
{
34-
Assert.AreEqual(expect, StringExtensions.DefaultIfNullOrEmpty(value, defaultValue));
30+
Assert.AreEqual(expect, value.DefaultIfNullOrEmpty(defaultValue));
3531
}
3632

3733
[Test]
@@ -44,7 +40,7 @@ public void TestDefaultIfNullOrEmptyWithDefaultValue(string value, string defaul
4440
[TestCase("\t", default(string))]
4541
public void TestDefaultIfNullOrWhitespace(string value, string expect)
4642
{
47-
Assert.AreEqual(expect, StringExtensions.DefaultIfNullOrWhitespace(value));
43+
Assert.AreEqual(expect, value.DefaultIfNullOrWhitespace());
4844
}
4945

5046
[Test]
@@ -58,13 +54,14 @@ public void TestDefaultIfNullOrWhitespace(string value, string expect)
5854
[TestCase("\t", "Default", "Default")]
5955
public void TestDefaultIfNullOrWhitespaceWithDefaultValue(string value, string defaultValue, string expect)
6056
{
61-
Assert.AreEqual(expect, StringExtensions.DefaultIfNullOrWhitespace(value, defaultValue));
57+
Assert.AreEqual(expect, value.DefaultIfNullOrWhitespace(defaultValue));
6258
}
6359

6460
[Test]
6561
[TestCase("this is a lowercase statement", false, "This Is A Lowercase Statement")]
6662
[TestCase("MS VS", false, "MS VS")]
67-
[TestCase("MSVS", true, "Msvs")]
63+
[TestCase("MASKS", true, "Masks")]
64+
[TestCase("", false, "")]
6865
public void TestTitleCase(string value, bool includeAllCaps, string expect)
6966
{
7067
Assert.AreEqual(expect, value.ToTitleCase(includeAllCaps));

src/ArbitraryExtensions/Core/StringExtensions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static class StringExtensions
1010

1111
/// <summary>Checks if the provided input is null or whitespace and returns the provided default value instead.</summary>
1212
/// <param name="input">the value to check</param>
13-
/// <param name="defaultValue">optional, the default value to return if input is null or whitepace.</param>
13+
/// <param name="defaultValue">optional, the default value to return if input is null or whitespace.</param>
1414
/// <returns>input if it's not null or whitespace, otherwise the provided default value.</returns>
1515
public static string DefaultIfNullOrWhitespace(this string input, string defaultValue = default) => string.IsNullOrWhiteSpace(input) ? defaultValue : input;
1616

@@ -21,10 +21,8 @@ public static class StringExtensions
2121
public static string ToTitleCase(this string text, bool includeAllCaps = false)
2222
{
2323
if (string.IsNullOrWhiteSpace(text)) return text;
24-
System.Globalization.TextInfo textInfo = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo;
24+
var textInfo = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo;
2525
return textInfo.ToTitleCase(includeAllCaps ? text.ToLower() : text);
2626
}
27-
28-
2927
}
3028
}

0 commit comments

Comments
 (0)