コード例 #1
0
        public void LoadSimpleTest()
        {
            ISongFileReader <OpenLyricsSong> target = new OpenLyricsSongFileReader();
            const string filename = "Resources/openlyrics/simple.xml";

            OpenLyricsSong expected = new OpenLyricsSong
            {
                Title             = "Amazing Grace",
                ModifiedTimestamp = "2012-04-10T22:00:00+10:00",
                CreatedIn         = "OpenLP 1.9.0",
                ModifiedIn        = "MyApp 0.0.1"
            };

            OpenLyricsSong.Verse verse = new OpenLyricsSong.Verse
            {
                Name = "v1"
            };

            OpenLyricsSong.TextLines lines = new OpenLyricsSong.TextLines();
            lines.Text.Add("Amazing grace how sweet the sound");
            lines.Text.Add("that saved a wretch like me;");
            verse.Lines.Add(lines);
            expected.Verses.Add(verse);

            var actual = target.Load(filename);

            Assert.AreEqual(expected.Title, actual.Title, "Wrong song title");
            Assert.AreEqual(expected.Title, actual.GetTitle(), "Wrong song title");
            Assert.AreEqual(expected.ModifiedTimestamp, actual.ModifiedTimestamp, "Wrong song modified date");
            Assert.AreEqual(expected.CreatedIn, actual.CreatedIn, "Wrong creator app");
            Assert.AreEqual(expected.ModifiedIn, actual.ModifiedIn, "Wrong modifier app");

            Assert.AreEqual(expected.Verses.Count, actual.Verses.Count, "Parts incomplete");
            for (int i = 0; i < expected.Verses.Count; i++)
            {
                Assert.AreEqual(expected.Verses[i].Name, actual.Verses[i].Name, "Wrong verse name");
                Assert.AreEqual(expected.Verses[i].Lines.Count, actual.Verses[i].Lines.Count, "Slides incomplete");
                for (int j = 0; j < expected.Verses[i].Lines.Count; j++)
                {
                    Assert.AreEqual(expected.Verses[i].Lines[j].Text.Count, actual.Verses[i].Lines[j].Text.Count, "Slide lines incomplete");
                    for (int k = 0; k < expected.Verses[i].Lines[j].Text.Count; k++)
                    {
                        Assert.AreEqual(expected.Verses[i].Lines[j].Text[k], actual.Verses[i].Lines[j].Text[k], "Wrong slide lyrics");
                    }
                }
            }
        }
コード例 #2
0
        public void LoadComplexTest()
        {
            ISongFileReader <OpenLyricsSong> target = new OpenLyricsSongFileReader();
            const string filename = "Resources/openlyrics/complex.xml";

            OpenLyricsSong expected = new OpenLyricsSong
            {
                Title             = "Amazing Grace",
                ModifiedTimestamp = "2012-04-10T22:00:00+10:00",
                CreatedIn         = "OpenLP 1.9.0",
                ModifiedIn        = "ChangingSong 0.0.1",
                CcliIdentifier    = "4639462",
                Copyright         = "public domain",
                ReleaseYear       = "1779"
            };

            expected.Comments.Add("This is one of the most popular songs in our congregation.");

            OpenLyricsSong.Verse verse = new OpenLyricsSong.Verse
            {
                Name     = "v1",
                Language = "en"
            };
            var lines = new OpenLyricsSong.TextLines();

            lines.Text.Add("Amazing grace how sweet the sound that saved a wretch like me;");
            verse.Lines.Add(lines);
            lines = new OpenLyricsSong.TextLines
            {
                Part = "women"
            };
            lines.Text.Add("A b c");
            lines.Text.Add("D e f");
            verse.Lines.Add(lines);
            expected.Verses.Add(verse);

            verse = new OpenLyricsSong.Verse
            {
                Name     = "v1",
                Language = "de"
            };
            lines = new OpenLyricsSong.TextLines();
            lines.Text.Add("Erstaunliche Ahmut, wie");
            verse.Lines.Add(lines);
            expected.Verses.Add(verse);

            verse = new OpenLyricsSong.Verse
            {
                Name = "c"
            };
            lines = new OpenLyricsSong.TextLines();
            lines.Text.Add("");
            lines.Text.Add("Line content.");
            verse.Lines.Add(lines);
            expected.Verses.Add(verse);

            verse = new OpenLyricsSong.Verse
            {
                Name     = "v2",
                Language = "en-US"
            };
            lines = new OpenLyricsSong.TextLines
            {
                Part = "men"
            };
            lines.Text.Add("");
            lines.Text.Add("Amazing grace how sweet the sound that saved a wretch like me;");
            lines.Text.Add("");
            lines.Text.Add("Amazing grace how sweet the sound that saved a wretch like me;");
            lines.Text.Add("Amazing grace how sweet the sound that saved a wretch like me;");
            verse.Lines.Add(lines);
            lines = new OpenLyricsSong.TextLines
            {
                Part = "women"
            };
            lines.Text.Add("A b c");
            lines.Text.Add("");
            lines.Text.Add("D e f");
            verse.Lines.Add(lines);
            expected.Verses.Add(verse);

            verse = new OpenLyricsSong.Verse
            {
                Name     = "emptyline",
                Language = "de"
            };
            lines = new OpenLyricsSong.TextLines();
            lines.Text.Add("");
            lines.Text.Add("");
            verse.Lines.Add(lines);
            lines = new OpenLyricsSong.TextLines();
            lines.Text.Add("");
            lines.Text.Add("");
            lines.Text.Add("");
            lines.Text.Add("");
            lines.Text.Add("");
            verse.Lines.Add(lines);
            expected.Verses.Add(verse);

            verse = new OpenLyricsSong.Verse
            {
                Name     = "e",
                Language = "de"
            };
            lines = new OpenLyricsSong.TextLines();
            lines.Text.Add("This is text of ending.");
            verse.Lines.Add(lines);
            expected.Verses.Add(verse);

            OpenLyricsSong actual = target.Load(filename);

            Assert.AreEqual(expected.Title, actual.Title, "Wrong song title");
            Assert.AreEqual(expected.ModifiedTimestamp, actual.ModifiedTimestamp, "Wrong song modified date");
            Assert.AreEqual(expected.CreatedIn, actual.CreatedIn, "Wrong creator app");
            Assert.AreEqual(expected.ModifiedIn, actual.ModifiedIn, "Wrong modifier app");
            Assert.AreEqual(expected.Copyright, actual.Copyright, "Wrong copyright info");
            Assert.AreEqual(expected.CcliIdentifier, actual.CcliIdentifier, "Wrong CCLI number");
            Assert.AreEqual(expected.ReleaseYear, actual.ReleaseYear, "Wrong release date");
            CollectionAssert.AreEqual(expected.Comments, actual.Comments, "Wrong comments");

            Assert.AreEqual(expected.Verses.Count, actual.Verses.Count, "Verses incomplete");
            for (int i = 0; i < expected.Verses.Count; i++)
            {
                Assert.AreEqual(expected.Verses[i].Name, actual.Verses[i].Name, "Wrong verse name");
                Assert.AreEqual(expected.Verses[i].Language, actual.Verses[i].Language, "Wrong language");
                Assert.AreEqual(expected.Verses[i].Lines.Count, actual.Verses[i].Lines.Count, "Slides incomplete " + i);
                for (int j = 0; j < expected.Verses[i].Lines.Count; j++)
                {
                    Assert.AreEqual(expected.Verses[i].Lines[j].Text.Count, actual.Verses[i].Lines[j].Text.Count, "Slide lines incomplete " + i + " " + j);
                    Assert.AreEqual(expected.Verses[i].Lines[j].Part, actual.Verses[i].Lines[j].Part, "Wrong lines part name");
                    for (int k = 0; k < expected.Verses[i].Lines[j].Text.Count; k++)
                    {
                        Assert.AreEqual(expected.Verses[i].Lines[j].Text[k], actual.Verses[i].Lines[j].Text[k], "Wrong slide lyrics");
                    }
                }
            }
        }