Пример #1
0
        public Song Parse(IList<string> soundtrackDefinition)
        {
            Song song = new Song();

            foreach (var songDetails in soundtrackDefinition)
            {
                if (SongTitleLineRegex.IsMatch(songDetails))
                {
                    song.Title = SongTitleLineRegex.Match(songDetails).Groups["title"].Value;
                    continue;
                }

                if (WriterLineRegex.IsMatch(songDetails))
                {
                    var writer = GetNamesFromRegex(songDetails, WriterLineRegex);
                    song.Composer = writer;
                    song.Lyricist = writer;

                    continue;
                }

                if (LycricistLineRegex.IsMatch(songDetails))
                {
                    song.Lyricist = GetNamesFromRegex(songDetails, LycricistLineRegex);
                    continue;
                }

                if (ComposerLineRegex.IsMatch(songDetails))
                {
                    song.Composer = GetNamesFromRegex(songDetails, ComposerLineRegex);
                    continue;
                }

                if (PerformerLineRegex.IsMatch(songDetails))
                {
                    song.Performer = GetNamesFromRegex(songDetails, PerformerLineRegex);
                    continue;
                }

                if (songDetails.Trim() == "Traditional")
                {
                    song.Composer = songDetails.Trim();
                    continue;
                }
            }

            return song;
        }
Пример #2
0
        public void TestParseCreatesValidObjectWithMultipleCrossReferencedWriters()
        {
            #region data = ...
            var data = @"- ""Boom""
              Written by 'E. Ray Goetz' (qv) (uncredited) and 'Charles Trenet' (qv) (uncredited)
              Performed by 'Carmen Silvera' (qv)
            ";
            #endregion

            IList<string> songDefinition = new List<string>(data.Split(new string[] { "\r\n" }, StringSplitOptions.None));
            var expected = new Song
            {
                Title = "Boom",
                Composer = "E. Ray Goetz (uncredited) and Charles Trenet (uncredited)",
                Lyricist = "E. Ray Goetz (uncredited) and Charles Trenet (uncredited)",
                Performer = "Carmen Silvera"
            };

            var logger = new Mock<ILog>();
            Song actual = new SongParser(logger.Object).Parse(songDefinition);

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void TestParseCreatesValidObjectWithCorrectlyFormattedDefinition()
        {
            #region data = ...
            var data = @"- ""Without a Dream""
              Music by 'Charles Fox (I)' (qv)
              Lyrics by 'Norman Gimbel' (qv)
              Performed by 'Ron Dante' (qv)";
            #endregion

            IList<string> songDefinition = new List<string>(data.Split(new string[] {"\r\n"}, StringSplitOptions.None));
            var expected = new Song
            {
                Title = "Without a Dream",
                Composer = "Charles Fox (I)",
                Lyricist = "Norman Gimbel",
                Performer = "Ron Dante"
            };

            var logger = new Mock<ILog>();
            Song actual = new SongParser(logger.Object).Parse(songDefinition);

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void TestParseCreatesValidObjectWithMultipleWriters()
        {
            #region data = ...
            var data = @"- ""Hear my song, Violetta"" (uncredited)
              Written by Othmar Klose, Rudolph Lukesch and 'Harry S. Pepper' (qv)
              Performed by 'Carmen Silvera' (qv)";
            #endregion

            IList<string> songDefinition = new List<string>(data.Split(new string[] { "\r\n" }, StringSplitOptions.None));
            var expected = new Song
            {
                Title = "Hear my song, Violetta",
                Composer = "Othmar Klose, Rudolph Lukesch and Harry S. Pepper",
                Lyricist = "Othmar Klose, Rudolph Lukesch and Harry S. Pepper",
                Performer = "Carmen Silvera"
            };

            var logger = new Mock<ILog>();
            Song actual = new SongParser(logger.Object).Parse(songDefinition);

            Assert.AreEqual(expected, actual);
        }