Esempio n. 1
0
        protected override void ParseAdditionalFields(XmlElement xmlRoot, PowerPraiseSong sng)
        {
            var song = (ExtendedPowerPraiseSong)sng;

            // Comment
            if (xmlRoot["general"] != null && xmlRoot["general"]["comment"] != null)
            {
                song.Comment = xmlRoot["general"]["comment"].InnerText;
            }
            else
            {
                song.Comment = "";
            }

            // Quality issues
            if (xmlRoot["general"] != null && xmlRoot["general"]["qualityissues"] != null)
            {
                ParseQualityIssues(song, xmlRoot["general"]["qualityissues"]);
            }

            // CCLI Song ID
            if (xmlRoot["general"] != null && xmlRoot["general"]["ccliNo"] != null)
            {
                song.CcliIdentifier = xmlRoot["general"]["ccliNo"].InnerText;
            }

            // Author(s)
            if (xmlRoot["general"] != null && xmlRoot["general"]["author"] != null)
            {
                song.Author = ParseAuthors(xmlRoot["general"]["author"].InnerText);
            }

            // Publisher
            if (xmlRoot["general"] != null && xmlRoot["general"]["publisher"] != null)
            {
                song.Publisher = xmlRoot["general"]["publisher"].InnerText;
            }

            // Rights management
            if (xmlRoot["general"] != null && xmlRoot["general"]["admin"] != null)
            {
                song.RightsManagement = xmlRoot["general"]["admin"].InnerText;
            }

            // Guid
            if (xmlRoot["general"] != null && xmlRoot["general"]["guid"] != null)
            {
                song.Guid = new Guid(xmlRoot["general"]["guid"].InnerText);
            }
        }
Esempio n. 2
0
        public void WriteUsingMapperSaveTest()
        {
            ISongFileMapper <PowerPraiseSong> mapper = new PowerPraiseSongFileMapper();
            ISongFileWriter <PowerPraiseSong> writer = new PowerPraiseSongFileWriter();
            const string referenceFilename           = "Resources/powerpraise/Näher, mein Gott zu Dir.ppl";
            const string filename = "Resources/powerpraise/Näher, mein Gott zu Dir - neu - extended2.ppl";

            Song            sng = PowerPraiseTestUtil.GetExpectedSong();
            PowerPraiseSong ppl = new PowerPraiseSong();

            mapper.Map(sng, ppl);
            writer.Save(filename, ppl);

            try
            {
                FileUtils.FileEquals(filename, referenceFilename, true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
        protected override void WriteAdditionalFields(XmlDocument xmlDoc, XmlElement xmlRoot, PowerPraiseSong ppl)
        {
            var sng = (ExtendedPowerPraiseSong)ppl;

            //
            // Non-standard meta-info
            //
            // GUID
            if (sng.Guid != Guid.Empty)
            {
                xmlRoot["general"].AppendChild(xmlDoc.CreateElement("guid"));
                xmlRoot["general"]["guid"].InnerText = sng.Guid.ToString();
            }

            // Comment
            if (sng.Comment != string.Empty)
            {
                xmlRoot["general"].AppendChild(xmlDoc.CreateElement("comment"));
                xmlRoot["general"]["comment"].InnerText = sng.Comment;
            }
            // QA-Issues
            if (sng.QualityIssues.Count > 0)
            {
                xmlRoot["general"].AppendChild(xmlDoc.CreateElement("qualityissues"));
                foreach (var i in sng.QualityIssues)
                {
                    var qaChld = xmlRoot["general"]["qualityissues"].AppendChild(xmlDoc.CreateElement("issue"));
                    qaChld.InnerText = Enum.GetName(typeof(SongQualityAssuranceIndicator), i);
                }
            }

            // CCLI-ID
            if (!string.IsNullOrEmpty(sng.CcliIdentifier))
            {
                xmlRoot["general"].AppendChild(xmlDoc.CreateElement("ccliNo"));
                xmlRoot["general"]["ccliNo"].InnerText = sng.CcliIdentifier;
            }

            // Author(s)
            if (sng.Author != null && sng.Author.Count > 0)
            {
                xmlRoot["general"].AppendChild(xmlDoc.CreateElement("author"));
                xmlRoot["general"]["author"].InnerText = writeAuthors(sng);
            }
            // Publisher
            if (!string.IsNullOrEmpty(sng.Publisher))
            {
                xmlRoot["general"].AppendChild(xmlDoc.CreateElement("publisher"));
                xmlRoot["general"]["publisher"].InnerText = sng.Publisher;
            }
            // Rights management
            if (!string.IsNullOrEmpty(sng.RightsManagement))
            {
                xmlRoot["general"].AppendChild(xmlDoc.CreateElement("admin"));
                xmlRoot["general"]["admin"].InnerText = sng.RightsManagement;
            }
        }
        public void LoadTest()
        {
            ISongFileReader <ExtendedPowerPraiseSong> reader = new ExtendedPowerPraiseSongFileReader();
            const string filename = "Resources/powerpraise/Näher, mein Gott zu Dir.ppl";

            PowerPraiseSong expected = PowerPraiseTestUtil.GetExpectedPowerPraiseSong();

            ExtendedPowerPraiseSong actual = reader.Load(filename);

            // General
            Assert.AreEqual(expected.Title, actual.Title, "Wrong song title");
            Assert.AreEqual(expected.Language, actual.Language, "Wrong language");
            Assert.AreEqual(expected.Category, actual.Category, "Wrong category");

            // Parts
            Assert.AreEqual(expected.Parts.Count, actual.Parts.Count, "Parts incomplete");
            for (int i = 0; i < expected.Parts.Count; i++)
            {
                Assert.AreEqual(expected.Parts[i].Caption, actual.Parts[i].Caption, "Wrong verse name in verse " + i);
                Assert.AreEqual(expected.Parts[i].Slides.Count, actual.Parts[i].Slides.Count, "Slides incomplete in verse " + i);
                for (int j = 0; j < expected.Parts[i].Slides.Count; j++)
                {
                    Assert.AreEqual(expected.Parts[i].Slides[j].Background, actual.Parts[i].Slides[j].Background);
                    Assert.AreEqual(expected.Parts[i].Slides[j].MainSize, actual.Parts[i].Slides[j].MainSize);
                    CollectionAssert.AreEqual(expected.Parts[i].Slides[j].Lines, actual.Parts[i].Slides[j].Lines, "Slide lines incomplete in verse " + i + " slide " + j);
                    CollectionAssert.AreEqual(expected.Parts[i].Slides[j].Translation, actual.Parts[i].Slides[j].Translation, "Slide translation incomplete in verse " + i + " slide " + j);
                }
            }

            // Order
            Assert.AreEqual(expected.Order.Count, actual.Order.Count, "Order incomplete");
            for (int i = 0; i < expected.Order.Count; i++)
            {
                Assert.AreEqual(expected.Order[i].Caption, actual.Order[i].Caption, "Wrong verse name in verse " + i);
            }

            // Copyright
            CollectionAssert.AreEqual(expected.CopyrightText, actual.CopyrightText, "Wrong copyright");
            Assert.AreEqual(expected.Formatting.CopyrightTextPosition, actual.Formatting.CopyrightTextPosition, "Wrong copyright text position");

            // Source
            Assert.AreEqual(expected.SourceText, actual.SourceText, "Wrong source text");
            Assert.AreEqual(expected.Formatting.SourceTextPosition, actual.Formatting.SourceTextPosition, "Wrong source text position");

            // Formatting
            Assert.AreEqual(expected.Formatting.MainText.Font, actual.Formatting.MainText.Font);
            Assert.AreEqual(expected.Formatting.MainText.Color.ToArgb(), actual.Formatting.MainText.Color.ToArgb());
            Assert.AreEqual(expected.Formatting.MainText.OutlineWidth, actual.Formatting.MainText.OutlineWidth);
            Assert.AreEqual(expected.Formatting.MainText.ShadowDistance, actual.Formatting.MainText.ShadowDistance);

            Assert.AreEqual(expected.Formatting.TranslationText.Font, actual.Formatting.TranslationText.Font);
            Assert.AreEqual(expected.Formatting.TranslationText.Color.ToArgb(), actual.Formatting.TranslationText.Color.ToArgb());
            Assert.AreEqual(expected.Formatting.TranslationText.OutlineWidth, actual.Formatting.TranslationText.OutlineWidth);
            Assert.AreEqual(expected.Formatting.TranslationText.ShadowDistance, actual.Formatting.TranslationText.ShadowDistance);

            Assert.AreEqual(expected.Formatting.CopyrightText.Font, actual.Formatting.CopyrightText.Font);
            Assert.AreEqual(expected.Formatting.CopyrightText.Color.ToArgb(), actual.Formatting.CopyrightText.Color.ToArgb());
            Assert.AreEqual(expected.Formatting.CopyrightText.OutlineWidth, actual.Formatting.CopyrightText.OutlineWidth);
            Assert.AreEqual(expected.Formatting.CopyrightText.ShadowDistance, actual.Formatting.CopyrightText.ShadowDistance);

            Assert.AreEqual(expected.Formatting.SourceText.Font, actual.Formatting.SourceText.Font);
            Assert.AreEqual(expected.Formatting.SourceText.Color.ToArgb(), actual.Formatting.SourceText.Color.ToArgb());
            Assert.AreEqual(expected.Formatting.SourceText.OutlineWidth, actual.Formatting.SourceText.OutlineWidth);
            Assert.AreEqual(expected.Formatting.SourceText.ShadowDistance, actual.Formatting.SourceText.ShadowDistance);

            Assert.AreEqual(expected.Formatting.Outline.Color.ToArgb(), actual.Formatting.Outline.Color.ToArgb());
            Assert.AreEqual(expected.Formatting.Outline.Enabled, actual.Formatting.Outline.Enabled);

            Assert.AreEqual(expected.Formatting.Shadow.Color.ToArgb(), actual.Formatting.Shadow.Color.ToArgb());
            Assert.AreEqual(expected.Formatting.Shadow.Direction, actual.Formatting.Shadow.Direction);
            Assert.AreEqual(expected.Formatting.Shadow.Enabled, actual.Formatting.Shadow.Enabled);

            // Linespacing
            Assert.AreEqual(expected.Formatting.MainLineSpacing, actual.Formatting.MainLineSpacing);
            Assert.AreEqual(expected.Formatting.TranslationLineSpacing, actual.Formatting.TranslationLineSpacing);

            // Text orientation
            Assert.AreEqual(expected.Formatting.TextOrientation, actual.Formatting.TextOrientation);
            Assert.AreEqual(expected.Formatting.TranslationPosition, actual.Formatting.TranslationPosition);

            // Borders
            Assert.AreEqual(expected.Formatting.Borders.TextLeft, actual.Formatting.Borders.TextLeft);
            Assert.AreEqual(expected.Formatting.Borders.TextTop, actual.Formatting.Borders.TextTop);
            Assert.AreEqual(expected.Formatting.Borders.TextRight, actual.Formatting.Borders.TextRight);
            Assert.AreEqual(expected.Formatting.Borders.TextBottom, actual.Formatting.Borders.TextBottom);
            Assert.AreEqual(expected.Formatting.Borders.CopyrightBottom, actual.Formatting.Borders.CopyrightBottom);
            Assert.AreEqual(expected.Formatting.Borders.SourceTop, actual.Formatting.Borders.SourceTop);
            Assert.AreEqual(expected.Formatting.Borders.SourceRight, actual.Formatting.Borders.SourceRight);
        }