示例#1
0
            public void EmptyObject_WithDate_CreatesExpectedFile()
            {
                WeekOfPuzzles weekOfPuzzles = new WeekOfPuzzles {
                    MondayOfWeekPosted = new DateTime(2019, 2, 25)
                };
                string fileName = $"EmptyObject_example_{Process.GetCurrentProcess().Id}.xml";

                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                weekOfPuzzles.Serialize(fileName);

                var actualText = File.ReadAllText(fileName);

                Assert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?>
<WeekOfPuzzles xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <SelectedWords>
    <string />
    <string />
    <string />
    <string />
    <string />
  </SelectedWords>
  <MondayOfWeekPosted>2019-02-25</MondayOfWeekPosted>
</WeekOfPuzzles>",
                                actualText);
            }
示例#2
0
            public void EmptyObject_WithDate_CreatesExpectedFile()
            {
                const string EMPTY_OBJECT_WITH_DATE = @"<?xml version=""1.0"" encoding=""utf-8""?>
<WeekOfPuzzles xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <SelectedWords>
    <string />
    <string />
    <string />
    <string />
    <string />
  </SelectedWords>
  <MondayOfWeekPosted>2019-02-25</MondayOfWeekPosted>
</WeekOfPuzzles>";
                string       fileName = $"EmptyObject_example_{Process.GetCurrentProcess().Id}.xml";

                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                File.WriteAllText(fileName, EMPTY_OBJECT_WITH_DATE);

                WeekOfPuzzles weekOfPuzzles = new WeekOfPuzzles();

                weekOfPuzzles.Deserialize(fileName);

                Assert.AreEqual(new DateTime(2019, 2, 25), weekOfPuzzles.MondayOfWeekPosted);
            }
示例#3
0
            public void PopulatedObject_CreatesExpectedFile()
            {
                WeekOfPuzzles weekOfPuzzles = new WeekOfPuzzles {
                    Theme = "WeeklyTheme"
                };
                WordSquare mondayWordSquare = new WordSquare("_____")
                {
                    Clues = new [] { "first clue", "second clue", "third clue", "fourth clue", "fifth clue" },
                    Theme = "Theme"
                };

                mondayWordSquare.SetWordAtIndex("acorn", 0);
                mondayWordSquare.SetWordAtIndex("curio", 1);
                int indexToSet = 2;

                mondayWordSquare.SetWordAtIndex("orals", indexToSet);
                mondayWordSquare.SetWordAtIndex("rille", 3);
                mondayWordSquare.SetWordAtIndex("nosed", 4);

                weekOfPuzzles.MondayWordSquare = mondayWordSquare;

                VowelMovement tuesdayVowelMovementPuzzle = new VowelMovement("The MICE MISS their MOOSE.")
                {
                    InitialConsonant = "m",
                    FinalConsonant   = "s",
                    Theme            = "Theme"
                };

                weekOfPuzzles.TuesdayVowelMovement = tuesdayVowelMovementPuzzle;

                ALittleAlliteration wednesdayAlliterationPuzzle = new ALittleAlliteration()
                {
                    Clue     = "Convey vegetable automobile",
                    Solution = "carry carrot car",
                    Theme    = "VegetableWeek"
                };

                weekOfPuzzles.WednesdayALittleAlliteration = wednesdayAlliterationPuzzle;


                string fileName = $"EmptyObject_example_{Process.GetCurrentProcess().Id}.xml";

                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                weekOfPuzzles.Serialize(fileName);

                var actualText = File.ReadAllText(fileName);

                Console.WriteLine(actualText);
                Assert.AreEqual(EXPECTED_TEXT, actualText);
            }
示例#4
0
            public void WithoutDate_SetsMondayToMinValue()
            {
                string fileName = $"testcase_{Process.GetCurrentProcess().Id}.xml";

                if (!File.Exists(fileName))
                {
                    File.WriteAllText(fileName, EXPECTED_TEXT);
                }
                WeekOfPuzzles weekOfPuzzles = new WeekOfPuzzles();

                weekOfPuzzles.Deserialize(fileName);

                Assert.AreEqual(DateTime.MinValue, weekOfPuzzles.MondayOfWeekPosted);
            }
示例#5
0
            public void ReturnsExpectedObject()
            {
                string fileName = $"testcase_{Process.GetCurrentProcess().Id}.xml";

                if (!File.Exists(fileName))
                {
                    File.WriteAllText(fileName, EXPECTED_TEXT);
                }
                WeekOfPuzzles weekOfPuzzles = new WeekOfPuzzles();

                weekOfPuzzles.Deserialize(fileName);

                Assert.IsNotNull(weekOfPuzzles.MondayWordSquare);
                Assert.IsNotNull(weekOfPuzzles.TuesdayVowelMovement);
                Assert.IsNotNull(weekOfPuzzles.WednesdayALittleAlliteration);
                Assert.AreEqual("WeeklyTheme", weekOfPuzzles.Theme);
            }