Example #1
0
        private static void TestNamePatternParse()
        {
            string      text    = "My Artist- 3 = My Title";
            NamePattern pattern = new NamePattern("Artist- TrackNumber = Title");

            IDictionary <FrameMeaning, string> variableMap = pattern.FromString(text);

            UnitTest.Test(variableMap[FrameMeaning.Artist] == "My Artist");
            UnitTest.Test(variableMap[FrameMeaning.TrackNumber] == "3");
            UnitTest.Test(variableMap[FrameMeaning.Title] == "My Title");
        }
Example #2
0
        private static void TestNamePatternFromString()
        {
            NamePattern pattern = new NamePattern("Artist - Album - Title - TrackNumber");
            string      text    = "My Artist - My Album - My Title - 03";

            IDictionary <FrameMeaning, string> words = pattern.FromString(text);

            UnitTest.Test(words[FrameMeaning.Artist] == "My Artist");
            UnitTest.Test(words[FrameMeaning.Album] == "My Album");
            UnitTest.Test(words[FrameMeaning.Title] == "My Title");
            UnitTest.Test(words[FrameMeaning.TrackNumber] == "03");
        }
Example #3
0
        private static void TestNamePatternFromStringFailure()
        {
            try
            {
                NamePattern pattern = new NamePattern("TrackNumber#Artist#Title");
                string      text    = "01-My Artist - My Title";

                IDictionary <FrameMeaning, string> words = pattern.FromString(text);

                UnitTest.Test(false);
            }
            catch (Exception)
            {
            }
        }
Example #4
0
        private static void TestNamePatternToString()
        {
            {
                Dictionary <FrameMeaning, string> dict = new Dictionary <FrameMeaning, string>();
                dict[FrameMeaning.Artist]      = "A";
                dict[FrameMeaning.Album]       = "B";
                dict[FrameMeaning.Title]       = "C";
                dict[FrameMeaning.TrackNumber] = "1";
                dict[FrameMeaning.ReleaseYear] = "1993";

                NamePattern pattern0 = new NamePattern("Artist - Album - Title - TrackNumber{ (ReleaseYear)}");
                UnitTest.Test(pattern0.HasMinimumRequiredWords(dict));
                UnitTest.Test(pattern0.ToString(dict) == "A - B - C - 1 (1993)");

                NamePattern pattern1 = new NamePattern("Artist.Title#TrackNumber");
                UnitTest.Test(pattern0.HasMinimumRequiredWords(dict));
                UnitTest.Test(pattern1.ToString(dict) == "A.C#1");
            }

            {
                Dictionary <FrameMeaning, string> dict = new Dictionary <FrameMeaning, string>();
                dict[FrameMeaning.Artist]      = "A";
                dict[FrameMeaning.Album]       = "B";
                dict[FrameMeaning.Title]       = "C";
                dict[FrameMeaning.TrackNumber] = "1";
                dict[FrameMeaning.ReleaseYear] = "";

                NamePattern pattern0 = new NamePattern("Artist - Album - Title - TrackNumber{ (ReleaseYear)}");
                UnitTest.Test(pattern0.HasMinimumRequiredWords(dict));
                UnitTest.Test(pattern0.ToString(dict) == "A - B - C - 1");

                NamePattern pattern1 = new NamePattern("Artist.Title#TrackNumber");
                UnitTest.Test(pattern0.HasMinimumRequiredWords(dict));
                UnitTest.Test(pattern1.ToString(dict) == "A.C#1");
            }
        }
Example #5
0
 public FileNameGenerator(string pattern)
 {
     Pattern = new NamePattern(pattern);
 }
Example #6
0
 public FileNameGenerator()
 {
     Pattern = new NamePattern(DefaultPattern);
 }
Example #7
0
 public DirectoryNameGenerator(string pattern)
 {
     Pattern = new NamePattern(pattern);
 }
Example #8
0
 public DirectoryNameGenerator()
 {
     Pattern = new NamePattern(DefaultPattern);
 }