feat: Finish FirstUpper
All checks were successful
Tests / Unit Testing1 (push) Successful in 45s

This commit is contained in:
Louis Gallet 2023-11-02 17:17:43 +01:00
parent a42e51b609
commit 3f42af8215
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY
2 changed files with 21 additions and 2 deletions

View File

@ -58,8 +58,17 @@ public class Iterations
return false;
}
public static bool FirstUpper(string s, string sub)
public static string FirstUpper(string s)
{
return true;
string phrase = s;
string[] word = s.Split(' ');
string result = String.Empty;
foreach (var element in word)
{
string first = element.Substring(0, 1);
result += first.ToUpper() + element.Substring(1) + " ";
}
return result.TrimEnd();
}
}

View File

@ -25,4 +25,14 @@ public class IterationTests
bool actual = Iteration.Iterations.FindSub(s, sub);
Assert.Equal(expected, actual);
}
[Theory]
[InlineData("Je me crois en enfer, donc j'y suis.", "Je Me Crois En Enfer, Donc J'y Suis.")]
[InlineData("!abc !def ghi .klm", "!abc !def Ghi .klm")]
public void CapitalizeTest(string s, string expected)
{
string actual = Iteration.Iterations.FirstUpper(s);
Assert.Equal(expected, actual);
}
}