Example #1
0
            public void WithPunctuation_ReturnsExpectedString()
            {
                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "i'm x."
                };
                puzzle.AddWordToClues("mix");

                puzzle.PlaceLetters();

                HtmlGenerator htmlGenerator = new HtmlGenerator {
                    Puzzle = puzzle
                };
                const string EXPECTED_HTML =
                    @"<tr>
	<td colspan=""2"">
	<input type=""text"" size=""1"" maxlength=""1"" id=""letter3"" onFocus=""colorMeAndMyMatch(3,'yellow');"" onBlur=""colorMeAndMyMatch(3,'white');"" 
	/>
	'
	<input type=""text"" size=""1"" maxlength=""1"" id=""letter4"" onFocus=""colorMeAndMyMatch(4,'yellow');"" onBlur=""colorMeAndMyMatch(4,'white');"" 
	/>
	&nbsp;
	&nbsp;
	<input type=""text"" size=""1"" maxlength=""1"" id=""letter5"" onFocus=""colorMeAndMyMatch(5,'yellow');"" onBlur=""colorMeAndMyMatch(5,'white');"" 
	/>
	.
	</td>
</tr>
";

                Assert.AreEqual(EXPECTED_HTML, htmlGenerator.CreateTableRowForPhrase());
            }
Example #2
0
            public void ReturnsExpectedResult()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                const string EXPECTED_HTML =
                    @"<tr>
	<td>
	Clue for example:
	</td>

	<td>
	<input type=""text"" size=""1"" maxlength=""1"" id=""letter0"" onFocus=""colorMeAndMyMatch(0,'yellow');"" onBlur=""colorMeAndMyMatch(0,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter1"" onFocus=""colorMeAndMyMatch(1,'yellow');"" onBlur=""colorMeAndMyMatch(1,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter2"" onFocus=""colorMeAndMyMatch(2,'yellow');"" onBlur=""colorMeAndMyMatch(2,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter3"" onFocus=""colorMeAndMyMatch(3,'yellow');"" onBlur=""colorMeAndMyMatch(3,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter4"" onFocus=""colorMeAndMyMatch(4,'yellow');"" onBlur=""colorMeAndMyMatch(4,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter5"" onFocus=""colorMeAndMyMatch(5,'yellow');"" onBlur=""colorMeAndMyMatch(5,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter6"" onFocus=""colorMeAndMyMatch(6,'yellow');"" onBlur=""colorMeAndMyMatch(6,'white');""
	/>
	</td>
</tr>
";

                Assert.AreEqual(EXPECTED_HTML, generator.CreateTableRowForWord(puzzle.Clues[0], 0));
            }
Example #3
0
            public void ReturnsExpectedResult()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                const string EXPECTED_HTML =
                    @"<tr>
	<td colspan=""2"">
	<input type=""text"" size=""1"" maxlength=""1"" id=""letter7"" onFocus=""colorMeAndMyMatch(7,'yellow');"" onBlur=""colorMeAndMyMatch(7,'white');"" 
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter8"" onFocus=""colorMeAndMyMatch(8,'yellow');"" onBlur=""colorMeAndMyMatch(8,'white');"" 
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter9"" onFocus=""colorMeAndMyMatch(9,'yellow');"" onBlur=""colorMeAndMyMatch(9,'white');"" 
	/>
	&nbsp;
	&nbsp;
	<input type=""text"" size=""1"" maxlength=""1"" id=""letter10"" onFocus=""colorMeAndMyMatch(10,'yellow');"" onBlur=""colorMeAndMyMatch(10,'white');"" 
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter11"" onFocus=""colorMeAndMyMatch(11,'yellow');"" onBlur=""colorMeAndMyMatch(11,'white');"" 
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter12"" onFocus=""colorMeAndMyMatch(12,'yellow');"" onBlur=""colorMeAndMyMatch(12,'white');"" 
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter13"" onFocus=""colorMeAndMyMatch(13,'yellow');"" onBlur=""colorMeAndMyMatch(13,'white');"" 
	/>
	</td>
</tr>
";

                Assert.AreEqual(EXPECTED_HTML, generator.CreateTableRowForPhrase());
            }
Example #4
0
            public void WithCustomClue_ReturnsExpectedString()
            {
                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "i'm x."
                };
                puzzle.AddWordToClues("mix");
                puzzle.Clues[0].CustomizedClue = "Customized Clue";
                puzzle.PlaceLetters();

                HtmlGenerator htmlGenerator = new HtmlGenerator {
                    Puzzle = puzzle
                };
                const string EXPECTED_HTML =
                    @"<tr>
	<td>
	Customized Clue:
	</td>

	<td>
	<input type=""text"" size=""1"" maxlength=""1"" id=""letter0"" onFocus=""colorMeAndMyMatch(0,'yellow');"" onBlur=""colorMeAndMyMatch(0,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter1"" onFocus=""colorMeAndMyMatch(1,'yellow');"" onBlur=""colorMeAndMyMatch(1,'white');""
	/><input type=""text"" size=""1"" maxlength=""1"" id=""letter2"" onFocus=""colorMeAndMyMatch(2,'yellow');"" onBlur=""colorMeAndMyMatch(2,'white');""
	/>
	</td>
</tr>
";

                Assert.AreEqual(EXPECTED_HTML, htmlGenerator.CreateTableRowForWord(puzzle.Clues[0], 0));
            }
Example #5
0
            public void GeneratesExpectedComment()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                string expectedComment =
                    @"/*
E 0 <-> 12
X 1 <-> 9
A 2 <-> 8
M 3 <-> 7
P 4 <-> 10
L 5 <-> 13
E 6 <-> 11

-----
M 7 <-> 3
A 8 <-> 2
X 9 <-> 1
 
P 10 <-> 4
E 11 <-> 6
E 12 <-> 0
L 13 <-> 5
*/
";

                Assert.AreEqual(expectedComment, generator.CreateComment());
            }
Example #6
0
            public void ReturnsExpectedString()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                const string EXPECTED_STRING =
                    @"var indexMap = [12, 9, 8, 7, 10, 13, 11, 3, 2, 1, 4, 6, 0, 5];";

                Assert.AreEqual(EXPECTED_STRING, generator.CreateIndexMapDefinition());
            }
Example #7
0
            public void WithPunctuation_ReturnsExpectedString()
            {
                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "i'm x."
                };
                puzzle.AddWordToClues("mix");

                puzzle.PlaceLetters();

                HtmlGenerator htmlGenerator = new HtmlGenerator {
                    Puzzle = puzzle
                };
                const string EXPECTED_STRING =
                    @"var indexMap = [4, 3, 5, 1, 0, 2];";

                Assert.AreEqual(EXPECTED_STRING, htmlGenerator.CreateIndexMapDefinition());
            }
Example #8
0
            public void CreatedExpectedFile()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                const string TEST_PUZZLE_FILENAME = "test_puzzle.html";

                string actualHtml = generator.GenerateHtmlFile(TEST_PUZZLE_FILENAME);

                Assert.AreEqual(File.ReadAllText(@"data\puzzle.html"), actualHtml);
                FileAssert.AreEqual(@"data\puzzle.html", TEST_PUZZLE_FILENAME);
            }
Example #9
0
            public void WithoutKey_CreatedExpectedFile()
            {
                HtmlGenerator generator = new HtmlGenerator();

                WordPuzzles.Puzzle.InnerAnacrosticPuzzle puzzle = new WordPuzzles.Puzzle.InnerAnacrosticPuzzle {
                    PhraseAsString = "max peel"
                };
                puzzle.AddWordToClues("example");
                puzzle.PlaceLetters();
                generator.Puzzle = puzzle;

                // ReSharper disable StringLiteralTypo
                const string TEST_PUZZLE_FILENAME      = "test_puzzle_withoutkey.html";
                const string EXPECTED_RESULTS_FILENAME = @"data\puzzle_withoutkey.html";
                // ReSharper restore StringLiteralTypo

                string actualHtml = generator.GenerateHtmlFile(TEST_PUZZLE_FILENAME, false);


                Assert.AreEqual(File.ReadAllText(EXPECTED_RESULTS_FILENAME), actualHtml);
                FileAssert.AreEqual(EXPECTED_RESULTS_FILENAME, TEST_PUZZLE_FILENAME);
            }