public void PhraseTest()
        {
            Phrase phrase = new Phrase("<name>, I am testing this phrase.", 5, 3, 0);

            Assert.AreEqual(phrase.Text, "<name>, I am testing this phrase.");
            Assert.AreEqual(phrase.NounPosition, 5);
            Assert.AreEqual(phrase.VerbPosition, 3);
            Assert.AreEqual(phrase.NamePosition, 0);
        }
        public void PhraseManagerTest()
        {
            PhraseManager manager = new PhraseManager("Blah");
            Phrase phrase1 = new Phrase("<name>, I am testing this phrase.", 5, 3, 0);
            Phrase phrase2 = new Phrase("So it's gonna be forever, or it's going to go down in flames!");
            Phrase phrase3 = new Phrase("And you love the game!", 4, 2);

            manager.AddPhrase(phrase1);
            manager.AddPhrase(phrase2);
            manager.AddPhrase(phrase3);

            Assert.AreEqual(manager.PhraseCount(), 3);
            Phrase phrase = manager.PhraseAt(1);
            Assert.AreEqual(phrase.Text, "So it's gonna be forever, or it's going to go down in flames!");

            phrase = manager.PhraseAt(2);
            Assert.AreEqual(phrase.VerbPosition, 2);
        }
Ejemplo n.º 3
0
        public int RemovePhrase(Phrase input)
        {
            if (!phrases.Contains(input))
            {
                return -1;
            }

            phrases.Remove(input);

            return 0;
        }
Ejemplo n.º 4
0
        public int AddPhrase(Phrase input)
        {
            if (!phrases.Contains(input))
            {
                phrases.Add(input);

                return 0;
            }

            return -1;
        }
Ejemplo n.º 5
0
        public async Task<int> Load(string path)
        {
            IFile file = await FileSystem.Current.GetFileFromPathAsync(path);

            if (file != null)
            {
                XDocument document = XDocument.Load(await file.OpenAsync(FileAccess.Read));

                if (document.Root.Value == "Phrases")
                {
                    foreach (XElement child in document.Root.Descendants())
                    {
                        Phrase currentPhrase = new Phrase(child.Value, 
                                                    int.Parse(child.Attribute("nounPos").Value),
                                                    int.Parse(child.Attribute("verbPos").Value),
                                                    int.Parse(child.Attribute("namePos").Value));

                        AddPhrase(currentPhrase);
                    }
                }
            }
            else
            {
                //throw new System.IO.InvalidDataException("Error: Could not load phrases.");
            }

            return 0;
        }