Test() 개인적인 메소드

private Test ( ) : void
리턴 void
예제 #1
0
        public static void Test_FileWalker()
        {
            string[] files =
            {
                VirtualDrive.VirtualFileName(@"Test_FileWalker\folder0\file0.bin"),
                VirtualDrive.VirtualFileName(@"Test_FileWalker\folder0\file1.bin"),
                VirtualDrive.VirtualFileName(@"Test_FileWalker\folder0\folder0\file0.bin"),
                VirtualDrive.VirtualFileName(@"Test_FileWalker\folder0\folder0\file1.bin"),
                VirtualDrive.VirtualFileName(@"Test_FileWalker\folder1\file2.bin"),
            };

            string[] expected =
            {
                "\\\\virtualdrive\\Test_FileWalker\\folder0\\folder0\\file0.bin",
                "\\\\virtualdrive\\Test_FileWalker\\folder0\\folder0\\file1.bin",
                "\\\\virtualdrive\\Test_FileWalker\\folder0\\file0.bin",
                "\\\\virtualdrive\\Test_FileWalker\\folder0\\file1.bin",
                "\\\\virtualdrive\\Test_FileWalker\\folder1\\file2.bin",
                "\\\\virtualdrive\\Test_FileWalker\\folder0\\folder0",
                "\\\\virtualdrive\\Test_FileWalker\\folder0",
                "\\\\virtualdrive\\Test_FileWalker\\folder1",
                "\\\\virtualdrive\\Test_FileWalker",
            };

            files.ForEach(n => VirtualDrive.Store(VirtualDrive.VirtualFileName(n), null));

            FileWalker walker = new FileWalker(VirtualDrive.VirtualFileName("Test_FileWalker"));

            UnitTest.Test(walker.Files.Concat(walker.Directories).SequenceEqual(expected));

            VirtualDrive.DeleteDirectory(VirtualDrive.VirtualFileName("Test_FileWalker"), true);
        }
예제 #2
0
        private static void TestVirtualDriveCopyDirectory()
        {
            string filename00 = VirtualDrive.VirtualFileName(@"Testdir0\testfile0.bin");
            string filename01 = VirtualDrive.VirtualFileName(@"Testdir0\testfile1.bin");

            string filename10 = VirtualDrive.VirtualFileName(@"Testdir1\testfile0.bin");
            string filename11 = VirtualDrive.VirtualFileName(@"Testdir1\testfile1.bin");

            VirtualDrive.Store(filename00, null);
            VirtualDrive.Store(filename01, null);

            UnitTest.Test(VirtualDrive.ExistsFile(filename00));
            UnitTest.Test(VirtualDrive.ExistsFile(filename01));
            UnitTest.Test(VirtualDrive.ExistsDirectory(
                              VirtualDrive.VirtualFileName("Testdir0")));

            VirtualDrive.CopyDirectory(
                VirtualDrive.VirtualFileName("Testdir0"),
                VirtualDrive.VirtualFileName("Testdir1"));

            UnitTest.Test(VirtualDrive.ExistsFile(filename00));
            UnitTest.Test(VirtualDrive.ExistsFile(filename01));
            UnitTest.Test(VirtualDrive.ExistsDirectory(
                              VirtualDrive.VirtualFileName("Testdir0")));
            UnitTest.Test(VirtualDrive.ExistsFile(filename10));
            UnitTest.Test(VirtualDrive.ExistsFile(filename11));
            UnitTest.Test(VirtualDrive.ExistsDirectory(
                              VirtualDrive.VirtualFileName("Testdir1")));

            VirtualDrive.DeleteDirectory(VirtualDrive.VirtualFileName("Testdir0"), true);
            VirtualDrive.DeleteDirectory(VirtualDrive.VirtualFileName("Testdir1"), true);
        }
예제 #3
0
파일: VirtualPath.cs 프로젝트: MRoc/puremp3
        public static void Test_Path_Parts()
        {
            string[] pathStrs =
            {
                @"C:\temp\folder0",
                @"\\virtualdrive\folder0",
            };

            string[][] expected =
            {
                new string[]
                {
                    "C:", "temp", "folder0"
                },
                new string[]
                {
                    "virtualdrive", "folder0"
                }
            };

            for (int i = 0; i < pathStrs.Length; ++i)
            {
                VirtualPath path = new VirtualPath(pathStrs[i]);
                UnitTest.Test(path.Parts.SequenceEqual(expected[i]));
            }
        }
예제 #4
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);
        }
예제 #5
0
        private static void TestVirtualDriveReWrite()
        {
            string fileName = VirtualDrive.VirtualFileName(
                @"TestID3VirtualDrive\file1");

            UnitTest.Test(!VirtualDrive.ExistsFile(fileName));

            Stream outStream0 = VirtualDrive.OpenOutStream(fileName);

            outStream0.WriteByte(0);
            outStream0.WriteByte(1);
            outStream0.WriteByte(2);
            outStream0.Close();

            UnitTest.Test(VirtualDrive.ExistsFile(fileName));
            UnitTest.Test(VirtualDrive.FileLength(fileName) == 3);

            Stream outStream1 = VirtualDrive.OpenOutStream(fileName);

            outStream1.WriteByte(5);
            outStream1.WriteByte(6);
            outStream1.Close();

            UnitTest.Test(VirtualDrive.ExistsFile(fileName));
            UnitTest.Test(VirtualDrive.FileLength(fileName) == 3);

            Stream inStream = VirtualDrive.OpenInStream(fileName);

            UnitTest.Test(inStream.ReadByte() == 5);
            UnitTest.Test(inStream.ReadByte() == 6);
            UnitTest.Test(inStream.ReadByte() == 2);
            inStream.Close();
        }
예제 #6
0
        private static void TestTagDescriptionFactoryMethods()
        {
            ID3.Version[] versions = ID3.Version.Versions;

            for (int i = 0; i < versions.Length; i++)
            {
                TagDescription tgm = TagDescriptionMap.Instance[versions[i]];

                UnitTest.Test(tgm.CreateTagCodec().IsSupported(versions[i]));
                UnitTest.Test(tgm.CreateFrameCodec().IsSupported(versions[i]));

                foreach (FrameDescription.FrameType frameType
                         in Enum.GetValues(typeof(FrameDescription.FrameType)))
                {
                    ID3.FrameContent content = tgm.CreateContent(frameType);

                    UnitTest.Test(content.Type == frameType || content.Type == FrameDescription.FrameType.Binary);
                }

                foreach (FrameDescription.FrameType frameType
                         in Enum.GetValues(typeof(FrameDescription.FrameType)))
                {
                    ID3.Codec.FrameContentCodecBase codec = tgm.CreateContentCodec(frameType);

                    UnitTest.Test(codec.Type == frameType || codec.Type == FrameDescription.FrameType.Binary);
                    UnitTest.Test(codec.IsSupported(versions[i]));
                }
            }
        }
예제 #7
0
        static void TestHistoryBasics()
        {
            DocList <IDocLeaf> testDoc = new DocList <IDocLeaf>();

            History.Instance.Root = testDoc;
            UnitTest.Test(History.Instance.HasUndo == false);
            UnitTest.Test(History.Instance.HasRedo == false);

            DocObj <int> testInt = new DocObj <int>(0);

            testDoc.Add(testInt);
            UnitTest.Test(History.Instance.HasUndo == true);
            UnitTest.Test(History.Instance.HasRedo == false);

            testInt.Value = 1;
            UnitTest.Test(testInt.Value == 1);
            testInt.Value = 2;
            UnitTest.Test(testInt.Value == 2);
            testInt.Value = 3;
            UnitTest.Test(testInt.Value == 3);

            History.Instance.Undo();
            UnitTest.Test(testInt.Value == 0);
            UnitTest.Test(History.Instance.HasRedo == true);
            History.Instance.Redo();
            UnitTest.Test(testInt.Value == 3);
        }
예제 #8
0
        private static void TestUndoFileWriter()
        {
            UndoFileWriter writer = new UndoFileWriter(
                VirtualDrive.VirtualFileName("TestUndoFileWriter.txt"));

            for (int i = 0; i < 4; i++)
            {
                List <string> parameters = new List <string>();
                for (int j = 0; j < i; j++)
                {
                    parameters.Add("line" + j);
                }

                writer.Write(new SerializedCommand(
                                 typeof(TestClass),
                                 SerializedCommand.UndoRedo.Do,
                                 "TestUndoFileWriter",
                                 parameters.ToArray()));
            }

            writer.Close();

            UnitTest.Test(VirtualDrive.FileLength(
                              VirtualDrive.VirtualFileName("TestUndoFileWriter.txt")) > 0);
        }
예제 #9
0
        private static void TestUndoFileReader()
        {
            UndoFileReader reader = new UndoFileReader(
                VirtualDrive.VirtualFileName("TestUndoFileWriter.txt"));

            UnitTest.Test(reader.NumCommands() == 4);

            for (int i = 3; i >= 0; i--)
            {
                SerializedCommand cmd = reader.CommandByIndex(i);
                UnitTest.Test(cmd.Target == typeof(TestClass).FullName);
                UnitTest.Test(cmd.Operation == "TestUndoFileWriter");

                UnitTest.Test(cmd.Data.Length == i);
                for (int j = 0; j < i; j++)
                {
                    UnitTest.Test(cmd.Data[j] == "line" + j);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                SerializedCommand cmd = reader.CommandByIndex(i);
                UnitTest.Test(cmd.Target == typeof(TestClass).FullName);
                UnitTest.Test(cmd.Operation == "TestUndoFileWriter");

                UnitTest.Test(cmd.Data.Length == i);
                for (int j = 0; j < i; j++)
                {
                    UnitTest.Test(cmd.Data[j] == "line" + j);
                }
            }

            reader.Close();
        }
예제 #10
0
파일: WebUtils.cs 프로젝트: MRoc/puremp3
        public static void TestEncodeUrl()
        {
            string expected = "h%23llo+w%23rld";
            string actual   = WebUtils.EncodeUrl("h#llo w#rld");

            UnitTest.Test(expected == actual);
        }
예제 #11
0
        public static void TestTagModelIsPlayingUpdater_IsPlaying()
        {
            PlayerModel model = new PlayerModel();

            TagModelList tml = DocNode.Create <TagModelList>();

            tml.SetFiles(TestTagModel.testFileNames);

            PlayerModelIsPlayingUpdater updater = new PlayerModelIsPlayingUpdater();

            updater.Model = model;
            updater.Items = tml.Items;

            for (int i = 0; i < tml.Items.Count; ++i)
            {
                model.CurrentModel.Value = tml[i];

                for (int j = 0; j < tml.Items.Count; ++j)
                {
                    UnitTest.Test(tml[j].IsPlaying.Value == (i == j));
                }
            }

            model.CurrentModel.Value = null;
        }
예제 #12
0
        private static void TestVersionConversionPath()
        {
            ID3.Version[] conversionPath = ID3.Version.BuildPath(
                ID3.Version.v2_0, ID3.Version.v2_0).ToArray();
            UnitTest.Test(conversionPath.Length == 1);
            UnitTest.Test(conversionPath[0] == ID3.Version.v2_0);

            conversionPath = ID3.Version.BuildPath(
                ID3.Version.v1_0, ID3.Version.v2_4).ToArray();
            UnitTest.Test(conversionPath.Length == 4);
            UnitTest.Test(conversionPath[0] == ID3.Version.v1_0);
            UnitTest.Test(conversionPath[1] == ID3.Version.v2_0);
            UnitTest.Test(conversionPath[2] == ID3.Version.v2_3);
            UnitTest.Test(conversionPath[3] == ID3.Version.v2_4);

            conversionPath = ID3.Version.BuildPath(
                ID3.Version.v2_4, ID3.Version.v1_0).ToArray();
            UnitTest.Test(conversionPath.Length == 4);
            UnitTest.Test(conversionPath[0] == ID3.Version.v2_4);
            UnitTest.Test(conversionPath[1] == ID3.Version.v2_3);
            UnitTest.Test(conversionPath[2] == ID3.Version.v2_0);
            UnitTest.Test(conversionPath[3] == ID3.Version.v1_0);

            conversionPath = ID3.Version.BuildPath(
                ID3.Version.v2_0, ID3.Version.v2_3).ToArray();
            UnitTest.Test(conversionPath.Length == 2);
            UnitTest.Test(conversionPath[0] == ID3.Version.v2_0);
            UnitTest.Test(conversionPath[1] == ID3.Version.v2_3);

            conversionPath = ID3.Version.BuildPath(
                ID3.Version.v2_3, ID3.Version.v2_0).ToArray();
            UnitTest.Test(conversionPath.Length == 2);
            UnitTest.Test(conversionPath[0] == ID3.Version.v2_3);
            UnitTest.Test(conversionPath[1] == ID3.Version.v2_0);
        }
예제 #13
0
 private static void TestVersionPreviousVersion()
 {
     UnitTest.Test(ID3.Version.PreviousVersion(ID3.Version.v1_0) == null);
     UnitTest.Test(ID3.Version.PreviousVersion(ID3.Version.v2_0).Equals(ID3.Version.v1_0));
     UnitTest.Test(ID3.Version.PreviousVersion(ID3.Version.v2_3).Equals(ID3.Version.v2_0));
     UnitTest.Test(ID3.Version.PreviousVersion(ID3.Version.v2_4).Equals(ID3.Version.v2_3));
 }
예제 #14
0
 private static void TestVersionFindIndex()
 {
     UnitTest.Test(ID3.Version.IndexOfVersion(ID3.Version.v1_0) == 0);
     UnitTest.Test(ID3.Version.IndexOfVersion(ID3.Version.v2_0) == 1);
     UnitTest.Test(ID3.Version.IndexOfVersion(ID3.Version.v2_3) == 2);
     UnitTest.Test(ID3.Version.IndexOfVersion(ID3.Version.v2_4) == 3);
 }
예제 #15
0
 private static void TestTagDescriptionMap()
 {
     UnitTest.Test(TagDescriptionMap.Instance[ID3.Version.v1_0] != null);
     UnitTest.Test(TagDescriptionMap.Instance[ID3.Version.v2_0] != null);
     UnitTest.Test(TagDescriptionMap.Instance[ID3.Version.v2_3] != null);
     UnitTest.Test(TagDescriptionMap.Instance[ID3.Version.v2_4] != null);
 }
예제 #16
0
        private static void TestGenericCodecComment()
        {
            byte[] data =
            {
                (byte)0,
                (byte)'e',(byte)'n',  (byte)'g',
                (byte)'D',(byte)'e',  (byte)'s',(byte)'c',  (byte)'r', (byte)'i',
                (byte)'p',(byte)'t',  (byte)'i',(byte)'o',  (byte)'n',
                (byte)0,
                (byte)'T',(byte)'e',  (byte)'x',(byte)'t',  (byte)'0',
                (byte)0,
                (byte)'T',(byte)'e',  (byte)'x',(byte)'t',  (byte)'1'
            };

            foreach (Version v in Version.vs2_0And2_3And2_4)
            {
                var fc = new FrameContentComment(TagDescriptionMap.Instance[v]);

                TestCodec(data, fc);

                UnitTest.Test((fc.Codec as FrameContentCodecGeneric).CurrentTextCodec == 0);
                UnitTest.Test(fc.Language == "eng");
                UnitTest.Test(fc.Description == "Description");
                UnitTest.Test(fc.Texts.Count() == 2);
                UnitTest.Test(fc.Texts.ElementAt(0) == "Text0");
                UnitTest.Test(fc.Texts.ElementAt(1) == "Text1");
            }
        }
예제 #17
0
        private static void TestTagDescriptionConversionMap()
        {
            ID3.Version[] versions = ID3.Version.Versions;

            for (int i = 0; i < versions.Length; i++)
            {
                TagDescription tgm = TagDescriptionMap.Instance[versions[i]];

                FrameConversionMap fcm = tgm.Conversion;
                foreach (string oldFrameId in fcm.OldFrameIds)
                {
                    UnitTest.Test(tgm.IsValidID(oldFrameId));
                }

                if (i < versions.Length - 1)
                {
                    foreach (string newFrameId in fcm.NewFrameIds)
                    {
                        TagDescription tgmNext = TagDescriptionMap.Instance[versions[i + 1]];

                        UnitTest.Test(tgmNext.IsValidID(newFrameId));
                    }
                }
            }
        }
예제 #18
0
        public static void Test_RelativeFileMove_MoveDirectory()
        {
            string[] srcFiles =
            {
                VirtualDrive.VirtualFileName(@"Test_RelativeFileMove_Move\folder0\file0.bin"),
                VirtualDrive.VirtualFileName(@"Test_RelativeFileMove_Move\folder0\folder0\file0.bin"),
            };
            string[] dstFiles =
            {
                VirtualDrive.VirtualFileName(@"Test_RelativeFileMove_Move\folder1\file0.bin"),
                VirtualDrive.VirtualFileName(@"Test_RelativeFileMove_Move\folder1\folder0\file0.bin"),
            };
            srcFiles.ForEach(n => VirtualDrive.Store(VirtualDrive.VirtualFileName(n), null));

            srcFiles.ForEach(n => UnitTest.Test(VirtualDrive.ExistsFile(n)));
            dstFiles.ForEach(n => UnitTest.Test(!VirtualDrive.ExistsFile(n)));

            SafeOperations.MoveDirectory(
                VirtualDrive.VirtualFileName(@"Test_RelativeFileMove_Move\folder0"),
                VirtualDrive.VirtualFileName(@"Test_RelativeFileMove_Move\folder1"));

            srcFiles.ForEach(n => UnitTest.Test(!VirtualDrive.ExistsFile(n)));
            dstFiles.ForEach(n => UnitTest.Test(VirtualDrive.ExistsFile(n)));

            VirtualDrive.DeleteDirectory(VirtualDrive.VirtualFileName("Test_RelativeFileMove_Move"), true);
        }
예제 #19
0
        static void TestDocObjSerialization()
        {
            DocObj <int> obj0 = new DocObj <int>(777);
            DocObj <int> obj1 = SerializeDeserialize(obj0);

            UnitTest.Test(obj0.Value == obj1.Value);
        }
예제 #20
0
        private static void TestVirtualDrivePaths()
        {
            string folder0 = VirtualDrive.VirtualFileName("folder");
            string parent0 = VirtualDrive.Parent(folder0);

            UnitTest.Test(parent0 == VirtualDriveImpl.virtualDrive);
        }
예제 #21
0
        static void TestPathBasics()
        {
            IDocLeaf doc = DocNode.Create <TestDocument>();

            string       pathToMyInt = "TestList.2";
            DocObj <int> myInt       = PathUtils.ChildByPath <DocObj <int> >(
                doc as IDocNode, pathToMyInt);

            UnitTest.Test(myInt.Value == 2);
            UnitTest.Test(PathUtils.PathByChild(myInt) == pathToMyInt);

            string        pathToMyBool = "TestBool";
            DocObj <bool> myBool       = PathUtils.ChildByPath <DocObj <bool> >(
                doc as IDocNode, pathToMyBool);

            UnitTest.Test(myBool.Value == true);
            UnitTest.Test(PathUtils.PathByChild(myBool) == pathToMyBool);

            string       pathToMyInt2 = "SubDoc.TestInt0";
            DocObj <int> myInt2       = PathUtils.ChildByPath <DocObj <int> >(
                doc as IDocNode, pathToMyInt2);

            UnitTest.Test(myInt2.Value == 2);
            UnitTest.Test(PathUtils.PathByChild(myInt2) == pathToMyInt2);
        }
예제 #22
0
        private static void TestFine()
        {
            string path = VirtualDrive.VirtualFileName(@"TestAlbumExplorerProcessor\TestFine\");
            TestTags.CreateDemoTags(path, 6, n => n.Album = "Album");

            AlbumExplorerProcessor processor = new AlbumExplorerProcessor();

            bool succeded = false;
            bool failed = false;

            processor.FineCallback += delegate(AlbumExplorer.AlbumResult album)
            {
                UnitTest.Test(album.Album.Result == AlbumExplorer.ParseResult.Fine);
                UnitTest.Test(album.Album[FrameMeaning.Artist] == "Artist");
                UnitTest.Test(album.Album[FrameMeaning.Album] == "Album");
                UnitTest.Test(album.Album[FrameMeaning.ReleaseYear] == "1993");

                succeded = true;
            };
            processor.BadCallback += delegate(AlbumExplorer.AlbumResult album)
            {
                failed = true;
            };

            processor.Process(new DirectoryInfo(path));

            UnitTest.Test(succeded);
            UnitTest.Test(!failed);

            VirtualDrive.DeleteDirectory(path, true);
        }
예제 #23
0
        private static void TestTagCodecV2(byte[] data, byte[] mcdiPayload)
        {
            Tag tag = new Tag(new TagCodecV2());

            using (Reader reader = new Reader(data))
            {
                tag.Read(reader);
            }

            UnitTest.Test(tag.Frames.Count() == 6);
            TagEditor editor = new TagEditor(tag);

            UnitTest.Test(editor.Album == "Album");
            UnitTest.Test(editor.Artist == "Artist");
            UnitTest.Test(editor.Title == "Title");
            UnitTest.Test(editor.Comment == "Comment");
            UnitTest.Test(editor.TrackNumber == "1");
            UnitTest.Test(ArrayUtils.IsEqual(editor.MusicCdIdentifier, mcdiPayload));

            using (Writer writer = new Writer())
            {
                tag.Write(writer);
                UnitTest.Test(ArrayUtils.IsEqual(writer.OutData, data));
            }
        }
예제 #24
0
        static void TestReaderStreamUnsynchronizationBytes()
        {
            byte[] src = new byte[] { 0xFF, 0, 0xFF, 0x1, 0xFF, 0x0, 0x0 };
            byte[] dst = new byte[] { 0xFF, 0xFF, 0x1, 0xFF, 0x0 };
            byte[] result = new byte[] { 0, 0, 0, 0, 0 };

            using (Reader reader = new Reader(src))
            {
                reader.Unsynchronization = true;

                using (ReaderStream stream = new ReaderStream(
                    reader, result.Length, Reader.UnsyncMode.CountExcludesUnsyncBytes))
                {
                    int numBytes = stream.Read(result, 0, result.Length);
                    UnitTest.Test(stream.Position == stream.Length);
                    UnitTest.Test(numBytes == result.Length);
                    UnitTest.Test(ArrayUtils.IsEqual(result, dst));
                }

                reader.Seek(0, SeekOrigin.Begin);

                using (ReaderStream stream = new ReaderStream(
                    reader, src.Length, Reader.UnsyncMode.CountIncludesUnsyncBytes))
                {
                    int numBytes = stream.Read(result, 0, src.Length);
                    UnitTest.Test(stream.Position == stream.Length);
                    UnitTest.Test(numBytes == result.Length);
                    UnitTest.Test(ArrayUtils.IsEqual(result, dst));
                }
            }
        }
예제 #25
0
        private static void TestFilenameToTagProcessorSimple()
        {
            string undoFilename = VirtualDrive.VirtualFileName(
                @"TestFilenameToTagProcessor\TestFilenameToTagProcessorUndoFile.txt");

            string filename = VirtualDrive.VirtualFileName(
                @"TestFilenameToTagProcessor\My Artist - 03 - My Title.mp3");

            string pattern = "Artist - TrackNumber - Title";

            VirtualDrive.Store(filename, TestTags.mpegDummy);

            FilenameToTagProcessor processor = new FilenameToTagProcessor();

            processor.ProcessMessage(new FilenameToTagProcessor.Message(pattern));

            using (UndoFileWriter undoFileWriter = new UndoFileWriter(undoFilename))
            {
                processor.UndoFile = undoFileWriter;
                processor.Process(new FileInfo(filename));
            }

            TagEditor editor = new TagEditor(TagUtils.ReadTag(new FileInfo(filename)));

            UnitTest.Test(editor.Artist == "My Artist");
            UnitTest.Test(editor.TrackNumber == "03");
            UnitTest.Test(editor.Title == "My Title");

            UndoFilePlayer.Undo(undoFilename);

            UnitTest.Test(Object.ReferenceEquals(TagUtils.ReadTag(new FileInfo(filename)), null));
        }
예제 #26
0
        static void TestReaderUnsynchronizationBytes()
        {
            byte[] src = new byte[] { 0xFF, 0, 0xFF, 0x1, 0xFF, 0x0, 0x0 };
            byte[] dst = new byte[] { 0xFF, 0xFF, 0x1, 0xFF, 0x0 };
            byte[] result = new byte[] { 0, 0, 0, 0, 0 };

            using (Reader reader = new Reader(src))
            {
                reader.Unsynchronization = true;

                int numBytes = reader.ReadBytes(result, 0, result.Length, Reader.UnsyncMode.CountExcludesUnsyncBytes);
                UnitTest.Test(reader.UnsynchronizationCounter == 2);
                UnitTest.Test(numBytes == result.Length);
                UnitTest.Test(ArrayUtils.IsEqual(result, dst));
            }

            using (Reader reader = new Reader(src))
            {
                reader.Unsynchronization = true;

                int numBytes = reader.ReadBytes(result, 0, src.Length, Reader.UnsyncMode.CountIncludesUnsyncBytes);
                UnitTest.Test(reader.UnsynchronizationCounter == 2);
                UnitTest.Test(numBytes == result.Length);
                UnitTest.Test(ArrayUtils.IsEqual(result, dst));
            }
        }
예제 #27
0
        static void TestReadWriteBigEndian4HighestBitZero()
        {
            int count = (1 << 16);

            for (int i = 0; i < count; i++)
            {
                byte[] data = null;
                using (Writer writer = new Writer())
                {
                    writer.WriteBigEndian4HighestBitZero(i);
                    data = writer.OutData;
                }

                UnitTest.Test(data.Length == 4);
                UnitTest.Test((data[0] & 0x80) == 0);
                UnitTest.Test((data[1] & 0x80) == 0);
                UnitTest.Test((data[2] & 0x80) == 0);
                UnitTest.Test((data[3] & 0x80) == 0);

                using (Reader reader = new Reader(data))
                {
                    int tmp = reader.ReadBigEndian4HighestBitZero();
                    UnitTest.Test(tmp == i);
                }
            }
        }
예제 #28
0
파일: FrameCodecs.cs 프로젝트: MRoc/puremp3
        private static void TestFrameCodec2_0()
        {
            byte[] data = new byte[]
            {
                // Frame ID
                (byte)'M', (byte)'C', (byte)'I',

                // Size
                0, 0, 0
            };

            FrameCodec2_0 codec = new FrameCodec2_0();
            Frame         frame = new Frame(TagDescriptionMap.Instance[Version.v2_0]);

            frame.Codec = codec;

            using (Reader reader = new Reader(data))
            {
                codec.ReadHeader(reader, frame);
                codec.ReadContent(reader, frame);
            }

            UnitTest.Test(frame.FrameId == "MCI");
            UnitTest.Test(codec.SizeContent == 0);

            using (Writer writer = new Writer())
            {
                codec.Write(writer, frame);
                UnitTest.Test(ArrayUtils.IsEqual(writer.OutData, data));
            }
        }
예제 #29
0
파일: FrameCodecs.cs 프로젝트: MRoc/puremp3
        private static void TestFrameCodec1_0()
        {
            byte[] data = new byte[]
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            FrameCodec1_0 codec = new FrameCodec1_0();
            Frame         frame = new Frame(TagDescriptionMap.Instance[Version.v1_0], "TT2");

            frame.Codec = codec;

            using (Reader reader = new Reader(data))
            {
                codec.ReadHeader(reader, frame);
                codec.ReadContent(reader, frame);
            }

            UnitTest.Test(codec.SizeContent == 30);

            using (Writer writer = new Writer())
            {
                codec.Write(writer, frame);
            }
        }
예제 #30
0
        public static void TestGoogleImageQuerySimple()
        {
            GoogleImageQuery query = new GoogleImageQuery();

            GoogleImageQuery.ImageResult result = query.Query("apple");
            UnitTest.Test(result.Url == "http://appleadayproject.files.wordpress.com/2011/03/apple-full2.jpg");
            UnitTest.Test(result.Image.Length == 10700);
        }