Exemplo n.º 1
0
        /// <summary>
        /// Retrieves the script for the given file path
        /// </summary>
        /// <param name="filePath">string filepath to a vaild file</param>
        /// <returns>DialogPrinter if the script is found and processed, null otherwise</returns>
        public IDialogPrinter GetForScript(string filePath)
        {
            IDialogPrinter printer = null;

            try
            {
                DialogGenerator gen = new DialogGenerator(filePath);

                switch (gen.GetPrinterType())
                {
                case GENERAL:
                    printer = new DialogPrinter(gen.GetLines());
                    break;

                case REPEATING:
                    printer = new RepeatingPrinter(gen.GetLines());
                    break;

                case BATTLE:
                    printer = new CustomPrinter(gen.GetLines());
                    break;
                }
            }
            catch (ScriptNotFoundException e)
            {
                Console.Out.WriteLine(e.Message);
            }

            return(printer);
        }
Exemplo n.º 2
0
        public void TestInvalidType()
        {
            DialogManager  mgmr      = new DialogManager();
            IDialogPrinter underTest = mgmr.GetForScript(INVALID_FILE_PATH);

            Assert.AreEqual("This should be findable, but exception was thrown", underTest.GetDialogLine());
            Assert.AreEqual("____END____", underTest.GetDialogLine());
        }
Exemplo n.º 3
0
        public void TestDialogPrinter()
        {
            DialogManager  mgmr      = new DialogManager();
            IDialogPrinter underTest = mgmr.GetForScript(FILEPATH);

            Assert.AreEqual("Arin : What do you say, suck my dick?", underTest.GetDialogLine());
            Assert.AreEqual("Danny : Arin!? Really!? I thought you'd never ask!", underTest.GetDialogLine());
            Assert.AreEqual("____END____", underTest.GetDialogLine());
        }
Exemplo n.º 4
0
        public void TestGenerator()
        {
            DialogManager  mgmr      = new DialogManager();
            IDialogPrinter underTest = mgmr.GetForScript(FILEPATH);

            string expectedActor = "Arin : What do you say, suck my dick?";

            Assert.AreEqual(expectedActor, underTest.GetDialogLine());
        }
Exemplo n.º 5
0
 public void TestGenerator_BadFilePath()
 {
     try
     {
         DialogManager  mgmr      = new DialogManager();
         IDialogPrinter underTest = mgmr.GetForScript(BAD_FILEPATH);
     }
     catch (ScriptNotFoundException e)
     {
         Assert.IsTrue(e.Message.Contains("The following script could not be found"));
     }
 }
Exemplo n.º 6
0
        public void TestBattlePrinter()
        {
            DialogManager  mgmr      = new DialogManager();
            IDialogPrinter underTest = mgmr.GetForScript(BATTLE_FILEPATH);

            string[] dmgTakenParams = new string[] { "Terra", "25" };
            Assert.AreEqual("Terra takes 25 points of damage.", string.Format(underTest.GetDialogLine(0), dmgTakenParams));

            string[] dmgDealtParams = new string[] { "Setzer", "Goblin", "12" };
            Assert.AreEqual("Setzer hits the Goblin for 12 points of damage.", string.Format(underTest.GetDialogLine(1), dmgDealtParams));

            string[] magDealtParams = new string[] { "Celes", "Ice", "Magitec Armor MkII", "150" };
            Assert.AreEqual("Celes casts Ice! The Magitec Armor MkII takes 150 points of damage.", string.Format(underTest.GetDialogLine(2), magDealtParams));

            //Check to see if extra parameters are ignored, in case they're accidentially sent
            string[] dmgTakenParams2 = new string[] { "Terra", "25", "35" };
            Assert.AreEqual("Terra takes 25 points of damage.", string.Format(underTest.GetDialogLine(0), dmgTakenParams2));
        }
Exemplo n.º 7
0
        public void TestRepeatingPrinter()
        {
            DialogManager  mgmr      = new DialogManager();
            IDialogPrinter underTest = mgmr.GetForScript(REPEATING_FILEPATH);

            int numLineOne  = 0;
            int numbLineTwo = 0;

            for (int i = 0; i < 10; i++)
            {
                string ret = underTest.GetDialogLine();
                Console.WriteLine(ret);
                if (ret.Equals("Welcome to Corneria"))
                {
                    numLineOne++;
                }
                else if (ret.Equals("I like swords"))
                {
                    numbLineTwo++;
                }
            }
            Assert.AreEqual(5, numLineOne);
            Assert.AreEqual(5, numbLineTwo);
        }