Skip to content

Commit

Permalink
The Word Wrap Kata
Browse files Browse the repository at this point in the history
  • Loading branch information
garora committed Mar 14, 2021
1 parent 5f34c0b commit 84299b0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/TheWordWrapKata/WordWrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@

namespace TDD_Katas_project.TheWordWrapKata
{
/// <summary>
/// Word Wrap
/// </summary>
public class WordWrap
{
#region Public Methods
/// <summary>
/// Wraps the specified word.
/// </summary>
/// <param name="word">The word.</param>
/// <param name="wordLength">Length of the word.</param>
/// <returns></returns>
public static string Wrap(string word, int wordLength)
{
var actualCount = 0;
Expand Down Expand Up @@ -34,9 +42,6 @@ public static string Wrap(string word, int wordLength)

return wrappedword;
}
#endregion

#region MyRegion

private static string GetWrappedwordWithoutBlankSpacesAtStartOfNewLine(string wrappedword)
{
Expand Down Expand Up @@ -71,7 +76,5 @@ private static string GetWrappedwordWithoutBlankSpacesAtStartOfNewLine(string wr
private static bool IsContainNullEmptyOrWhiteSpaces(string word) => (string.IsNullOrEmpty(word)) || (string.IsNullOrWhiteSpace(word));

private static bool IsWhiteSpaceOrNewLine(char wrd) => char.IsWhiteSpace(wrd) && (wrd == '\n');

#endregion
}
}
}
20 changes: 18 additions & 2 deletions src/TheWordWrapKata/WordWrapTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,44 @@

namespace TDD_Katas_project.TheWordWrapKata
{
/// <summary>
/// The Word Wrap Kata
/// </summary>
[TestFixture]
[Category("The Word Wrap Kata")]
public class WordWrapTest
{
/// <summary>
/// Determines whether this instance [can wrap single line].
/// </summary>
[Test]
public void CanWrapSingleLine() => Assert.That("Let's\nGo", Is.EqualTo(WordWrap.Wrap("Let's Go", 5)));

/// <summary>
/// Determines whether this instance [can test for null word].
/// </summary>
[Test]
public void CanTestForNullWord() => Assert.That("", Is.EqualTo(WordWrap.Wrap(null, 5)));

/// <summary>
/// Determines whether this instance [can test for null or white spaces word].
/// </summary>
[Test]
public void CanTestForNullOrWhiteSpacesWord()
{
Assert.That("", Is.EqualTo(WordWrap.Wrap(null, 5)));
Assert.That("", Is.EqualTo(WordWrap.Wrap(" ", 5)));
}
/// <summary>
/// Determines whether this instance [can test new line character].
/// </summary>
[Test]
public void CanTestNewLineCharacter()
{
Assert.That("\n", Is.EqualTo(WordWrap.Wrap("\n", 1)));
Assert.That("\nLet's\nGo\noutside.", Is.EqualTo(WordWrap.Wrap("\nLet's Go\noutside.", 5)));
}
/// <summary>
/// Determines whether this instance [can wrap multiple line].
/// </summary>
[Test]
public void CanWrapMultipleLine()
{
Expand Down

0 comments on commit 84299b0

Please sign in to comment.