Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre kata review #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ packages/
/packages/jQuery.1.10.2/Tools/*.js
/packages/jQuery.1.10.2/*.nupkg
.vs/
.idea/
2 changes: 2 additions & 0 deletions Scrabble.Lib.Test/Scrabble.Lib.Test/GameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ public void CreateWordsAndScores()
}

[Test]
[Ignore("Ignore for now")]
public void ThenHas7Tiles()
{
LayTheWords();
Expand Down Expand Up @@ -418,6 +419,7 @@ public void CreateWordsAndScores()
}

[Test]
[Ignore("Ignore for now")]
public void ThenPlayerReceivesAll()
{
LayTheWords();
Expand Down
138 changes: 93 additions & 45 deletions Scrabble.Lib.Test/Scrabble.Lib.Test/WordScoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ protected void LayTheWords()
ScrabbleGame.LayWord(i % 2 == 0 ? "Victoria" : "Albert", Words[i]);
var result = ScrabbleGame.AcceptWord();
Assert.That(result.ValidWord, Is.True);
Assert.That(result.PlayerScore, Is.EqualTo(ExpectedScores[i]));

var tiles = Words[i].Aggregate("", (s, tp) => s + tp.Tile.Letter);
Assert.That(result.PlayerScore, Is.EqualTo(ExpectedScores[i]),
$"Incorrect score for tiles '{tiles}': expected {ExpectedScores[i]}, actual {result.PlayerScore}");
}
}
}

//TODO: Start here

#region Initial word must go through the centre square, and scores double the tile values (centre square is effectively a Double Word Score)

public class LayingFirstWord : WordsTest
{
/*
Expand All @@ -57,8 +61,10 @@ public void CreateWordsAndScores()
{
PlayerNames = new[] { "Victoria" };

Words = new[] {
new[] {
Words = new[]
{
new[]
{
TilePoint.Create('H', "H8"),
TilePoint.Create('E', "I8"),
TilePoint.Create('N', "J8")
Expand All @@ -74,57 +80,64 @@ public void ThenScoresExtendedWord()
LayTheWords();
}
}

#endregion

#region Initial word is extended horizontally with suffix

/*Scores value of all letter tiles (no new bonus squares used)*/
//public class ExtendingAWordHorizontallySuffix : WordsTest
//{
// /*
// Word 1 (H on centre) =
// |H|E| | |
// | | | | |
// | | | | |
// *
// Word 2 =
// |H|E|A|D|
// | | | | |
// | | | | |
// */
public class ExtendingAWordHorizontallySuffix : WordsTest
{
/*
Word 1 (H on centre) =
|H|E| | |
| | | | |
| | | | |
*
Word 2 =
|H|E|A|D|
| | | | |
| | | | |
*/

// public ExtendingAWordHorizontallySuffix()
// {
// TilesToSelect = "HEABCDE" + "ADFGHIJ" + "ABCDE";
// }
public ExtendingAWordHorizontallySuffix()
{
TilesToSelect = "HEABCDE" + "ADFGHIJ" + "ABCDE";
}

// [SetUp]
// public void CreateWordsAndScores()
// {
// PlayerNames = new[] { "Victoria" };
[SetUp]
public void CreateWordsAndScores()
{
PlayerNames = new[] { "Victoria" };

// Words = new[] {
// new[] {
// TilePoint.Create('H', "H8"),
// TilePoint.Create('E', "H9")
// },
// new[] {
// TilePoint.Create('A', "H10"),
// TilePoint.Create('D', "H11"),
// }
// };
Words = new[]
{
new[]
{
TilePoint.Create('H', "H8"),
TilePoint.Create('E', "H9")
},
new[]
{
TilePoint.Create('A', "H10"),
TilePoint.Create('D', "H11"),
}
};

// ExpectedScores = new[] { 10, 8 };
// }
ExpectedScores = new[] { 10, 8 };
}

[Test]
public void ThenScoresExtendedWord()
{
LayTheWords();
}
}

// [Test]
// public void ThenScoresExtendedWord()
// {
// LayTheWords();
// }
//}
#endregion

#region Initial word is extended horizontally with prefix
#region Initial word is extended horizontally with prefix

//Scores value of all letter tiles (no new bonus squares used)
//public class ExtendingAWordHorizontallyPrefix : WordsTest
//{
Expand Down Expand Up @@ -169,9 +182,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is extended vertically with suffix

//Scores value of all letter tiles (no new bonus squares used)
//public class ExtendingAWordVerticallySuffix : WordsTest
//{
Expand Down Expand Up @@ -218,9 +233,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is extended vertically with prefix

//Scores value of all letter tiles (no new bonus squares used)
//public class ExtendingAWordVerticallyPrefix : WordsTest
//{
Expand Down Expand Up @@ -265,9 +282,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is extended by a horizontal word below
#region Initial word is extended by a horizontal word below

//Scores value of all letter tiles for both words
//public class ExtendingAWordUnderneath : WordsTest
//{
Expand Down Expand Up @@ -317,9 +336,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is extended by a horizontal word below
#region Initial word is extended by a horizontal word below

//Scores new word(+ bonuses) + (tile + bonus) for the letter extending the word + (tile scores without bonus) for existing tiles in extended word.
//public class ExtendingAWordUnderneathWithLetterBonus : WordsTest
//{
Expand Down Expand Up @@ -366,9 +387,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is extended by a horizontal word above

//public class ExtendingAWordAbove : WordsTest
//{
// /*
Expand Down Expand Up @@ -412,9 +435,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is extended by a vertical word to the left

//public class ExtendingAWordLeft : WordsTest
//{
// /*
Expand Down Expand Up @@ -458,9 +483,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is extended by a vertical word to the right

//public class ExtendingAWordRight : WordsTest
//{
// /*
Expand Down Expand Up @@ -504,9 +531,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is intersected. Just scores points for the tiles laid (+ bonuses)

//public class CrossingAWordVertically : WordsTest
//{
// /*
Expand Down Expand Up @@ -552,9 +581,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Initial word is intersected. Just scores points for the tiles laid (+ bonuses)

//public class CrossingAWordHorizontally : WordsTest
//{
// /*
Expand Down Expand Up @@ -599,9 +630,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region New word intersects an existing word, and creates two additional new words

// public class ExtendingMultipleWords : WordsTest
// {
// /*
Expand Down Expand Up @@ -679,9 +712,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
// }

#endregion

#region Laying all tiles in one go scores a nonus 50 points

//public class UsingAllTiles : WordsTest
//{
// /*
Expand Down Expand Up @@ -735,9 +770,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region New word extends initial word, spans two bonus squares and uses all tiles

//public class SpanTwoWordBonusSquares : WordsTest
//{
// /*
Expand Down Expand Up @@ -788,9 +825,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Single tile creates a horizontal word between two existing tiles

//public class BridgingTwoLettersHorizontally : WordsTest
//{
// /*
Expand Down Expand Up @@ -856,9 +895,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Single tile creates a vertical word between two existing tiles

//public class BridgingTwoLettersVertically : WordsTest
//{
// /*
Expand Down Expand Up @@ -921,9 +962,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Single tile creates horizontal and vertical words between existing tiles

//public class FillingASquareWithSingleTile : WordsTest
//{
// /*
Expand Down Expand Up @@ -992,9 +1035,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Multiple tiles create a new horizontal word and two vertical words between existing tiles

//public class FillingASquareWithMultipleTilesHorizontally : WordsTest
//{
// /*
Expand Down Expand Up @@ -1056,9 +1101,11 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion

#region Multiple tiles create a new vertical word and two horizontal words between existing tiles

//public class FillingASquareWithMultipleTilesVertically : WordsTest
//{
// /*
Expand Down Expand Up @@ -1120,6 +1167,7 @@ public void ThenScoresExtendedWord()
// LayTheWords();
// }
//}

#endregion
}
}
Loading