Пример #1
0
        private static void TestFileProcessorRecordAndPlay()
        {
            string undoFileName = VirtualDrive.VirtualFileName(
                @"TestFileProcessorRecordAndPlay\UndoFile.txt");

            FileInfo[] fileInfos =
                (from x in TestTags.Demotags select VirtualDrive.CreateVirtualFileInfo(
                     @"TestFileProcessorRecordAndPlay\TestFileProcessor" + x + ".mp3")).ToArray();

            fileInfos.ForEach((n) => TagUtils.WriteTag(TestTags.CreateDemoTag(Version.v2_0), n));

            using (UndoFileWriter undoFileWriter = new UndoFileWriter(undoFileName))
            {
                FileProcessor processor = new FileProcessor(new TagVersionProcessor(Version.v2_3));
                processor.UndoFile = undoFileWriter;

                foreach (var obj in fileInfos)
                {
                    processor.Process(obj);
                }
            }

            fileInfos.ForEach((n) => UnitTest.Test(TagUtils.ReadVersion(n) == Version.v2_3));

            UndoFilePlayer.Undo(undoFileName);

            fileInfos.ForEach((n) => UnitTest.Test(TagUtils.ReadVersion(n) == Version.v2_0));

            UndoFilePlayer.Redo(undoFileName);

            fileInfos.ForEach((n) => UnitTest.Test(TagUtils.ReadVersion(n) == Version.v2_3));

            VirtualDrive.DeleteDirectory(VirtualDrive.VirtualFileName(
                                             @"TestFileProcessorRecordAndPlay"), true);
        }
Пример #2
0
        static void TestCreateTrackNumbers()
        {
            Tag[] tags =
            {
                TestTags.CreateDemoTag(Version.v2_3),
                TestTags.CreateDemoTag(Version.v2_3),
                TestTags.CreateDemoTag(Version.v2_3)
            };

            string[] patterns =
            {
                "0",
                "00",
                "0/0",
                "00/00",
                "0 0",
            };
            string[,] expected =
            {
                { "1",     "2",     "3"     },
                { "01",    "02",    "03"    },
                { "1/3",   "2/3",   "3/3"   },
                { "01/03", "02/03", "03/03" },
                { "1 3",   "2 3",   "3 3"   },
            };

            for (int i = 0; i < patterns.Length; i++)
            {
                TagProcessorTrackNumber processor = new TagProcessorTrackNumber(
                    new TrackNumberGenerator(patterns[i]));

                for (int j = 0; j < tags.Length; j++)
                {
                    processor.ProcessMessage(new DirectoryProcessor.Message(tags.Length, j));
                    processor.Process(tags[j]);
                }

                for (int j = 0; j < tags.Length; j++)
                {
                    UnitTest.Test(new TagEditor(tags[j]).TrackNumber == expected[i, j]);
                }
            }
        }