public void TestWorldValidator_DialogueOptionWithMissingDestination()
        {
            var w = new WorldFactory {
                ResourcesDirectory = EmptyDir
            }.Create();
            var v = new WorldValidator();

            var d = new DialogueNode()
            {
                Identifier = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905"),
                Body       = new List <TextBlock>
                {
                    new TextBlock("I dare say")
                },
                Options =
                {
                    new DialogueOption()
                    {
                        Text = "Rather!",

                        //This is missing
                        Destination = new Guid("d7bcff5f-31a4-41ad-a71e-9b51a6565fc3")
                    }
                }
            };

            w.Dialogue.AllDialogues.Add(d);

            v.ValidateDialogue(w, w.Player, new DialogueInitiation()
            {
                Next = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            }, w.Player.CurrentLocation);

            StringAssert.Contains("Could not find Dialogue 'd7bcff5f-31a4-41ad-a71e-9b51a6565fc3", v.Errors.ToString());
        }
        public void TestWorldValidator_DialogueOptionWithNoText()
        {
            var world =
                new WorldFactory {
                ResourcesDirectory = EmptyDir
            }
            .Create();

            var v = new WorldValidator();

            var d = new DialogueNode()
            {
                Identifier = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905"),
                Body       = new List <TextBlock>
                {
                    new TextBlock("I dare say")
                },
                Options = { new DialogueOption() }
            };

            world.Dialogue.AllDialogues.Add(d);

            v.ValidateDialogue(world, world.Player, new DialogueInitiation()
            {
                Next = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            }, world.Player.CurrentLocation);

            StringAssert.Contains("A Dialogue Option of Dialogue '1cf15faf-837b-4629-84c5-bdfa7631a905' has no Text", v.Errors.ToString());
        }
        public void TestWorldValidator_DialogueWithNoText()
        {
            var w = new WorldFactory {
                ResourcesDirectory = EmptyDir
            }.Create();
            var v = new WorldValidator();

            var d = new DialogueNode()
            {
                Identifier = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            };

            w.Dialogue.AllDialogues.Add(d);

            v.ValidateDialogue(w, w.Player, new DialogueInitiation()
            {
                Next = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            }, w.Player.CurrentLocation);

            StringAssert.Contains("Dialogue '1cf15faf-837b-4629-84c5-bdfa7631a905' has no Body Text", v.Errors.ToString());
        }
        [TestCase("sdf sdf sdf", "syntax error near 'sdf'")] // bad compile time value
        public void TestWorldValidator_DialogueOptionWithBadEffectCode(string badCode, string expectedError)
        {
            var w = new WorldFactory {
                ResourcesDirectory = EmptyDir
            }.Create();
            var v = new WorldValidator();

            var d = new DialogueNode()
            {
                Identifier = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905"),
                Body       = new List <TextBlock>
                {
                    new TextBlock("I dare say")
                },
                Options =
                {
                    new DialogueOption()
                    {
                        Text   = "Do stuff",
                        Effect =
                        {
                            new EffectCode(badCode)
                        }
                    }
                }
            };

            w.Dialogue.AllDialogues.Add(d);

            v.ValidateDialogue(w, w.Player, new DialogueInitiation()
            {
                Next = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            }, w.Player.CurrentLocation);


            StringAssert.Contains("Error testing EffectCode of Option 'Do stuff' of Dialogue '1cf15faf-837b-4629-84c5-bdfa7631a905'", v.Warnings.ToString());
            StringAssert.Contains(expectedError, v.Warnings.ToString());
        }
        public void TestWorldValidator_BadConditionCode()
        {
            var w = new WorldFactory {
                ResourcesDirectory = EmptyDir
            }.Create();
            var v = new WorldValidator();

            var d = new DialogueNode()
            {
                Identifier = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905"),
                Condition  = { new ConditionCode("Tr oll oll = 1") }
            };

            w.Dialogue.AllDialogues.Add(d);

            v.ValidateDialogue(w, w.Player, new DialogueInitiation()
            {
                Next = new Guid("1cf15faf-837b-4629-84c5-bdfa7631a905")
            }, w.Player.CurrentLocation);

            StringAssert.Contains("Error testing dialogue condition on '1cf15faf-837b-4629-84c5-bdfa7631a905'", v.Warnings.ToString());
            StringAssert.Contains("<eof> expected near 'oll'", v.Warnings.ToString());
        }