예제 #1
0
        private void audio_X_AAC_MP4_Atom(string atom, string atomCaption = null)
        {
            if (null == atomCaption)
            {
                atomCaption = atom;
            }

            ArrayLogger log              = new ArrayLogger();
            string      resource         = "AAC/mp4.m4a";
            string      location         = TestUtils.GetResourceLocationRoot() + resource;
            string      testFileLocation = TestUtils.CopyAsTempTestFile(resource);

            using (FileStream fs = new FileStream(testFileLocation, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
            {
                StreamUtils.FindSequence(fs, Utils.Latin1Encoding.GetBytes(atom));
                fs.Seek(-1, SeekOrigin.Current);
                fs.WriteByte(0);

                Track           theTrack = new Track(fs, ".mp4");
                IList <LogItem> logItems = log.GetAllItems(Log.LV_ERROR);
                Assert.AreEqual(1, logItems.Count);
                Assert.AreEqual(atomCaption + " atom could not be found; aborting read", logItems[0].Message);
            }

            // Get rid of the working copy
            File.Delete(testFileLocation);
        }
예제 #2
0
        public void Audio_X_APE_invalid()
        {
            // Source : APE with invalid header
            ArrayLogger log      = new ArrayLogger();
            string      location = TestUtils.GetResourceLocationRoot() + "MP3/invalidApeHeader.mp3";

            new Track(location);

            IList <LogItem> logItems = log.GetAllItems(LV_ERROR);

            Assert.AreEqual(1, logItems.Count);
            Assert.AreEqual("Invalid value found while reading APEtag frame", logItems[0].Message);
        }
예제 #3
0
        public void PL_Common()
        {
            IPlaylistReader theReader = PlaylistReaders.PlaylistReaderFactory.GetInstance().GetPlaylistReader(TestUtils.GetResourceLocationRoot() + "_Playlists/playlist_simple.m3u");

            Assert.AreEqual(TestUtils.GetResourceLocationRoot() + "_Playlists/playlist_simple.m3u", theReader.Path);

            ArrayLogger log = new ArrayLogger();

            try
            {
                theReader = PlaylistReaders.PlaylistReaderFactory.GetInstance().GetPlaylistReader(TestUtils.GetResourceLocationRoot() + "_Playlists/efiufhziuefizeub.m3u");
                theReader.GetFiles();
                Assert.Fail();
            } catch {
                IList <LogItem> logItems = log.GetAllItems(Log.LV_ERROR);
                Assert.AreEqual(1, logItems.Count);
                Assert.IsTrue(logItems[0].Message.Contains("efiufhziuefizeub.m3u")); // Can't do much more than than because the exception message is localized
            }
        }
        private void audio_X_MP4_Atom(string resourceName, string atom, int logLevel = Log.LV_ERROR, string atomCaption = null)
        {
            if (null == atomCaption)
            {
                atomCaption = atom;
            }

            ArrayLogger log              = new ArrayLogger();
            string      resource         = "MP4/" + resourceName;
            string      testFileLocation = TestUtils.CopyAsTempTestFile(resource);

            using (FileStream fs = new FileStream(testFileLocation, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
            {
                StreamUtils.FindSequence(fs, Utils.Latin1Encoding.GetBytes(atom));
                fs.Seek(-1, SeekOrigin.Current);
                fs.WriteByte(0);
                if (StreamUtils.FindSequence(fs, Utils.Latin1Encoding.GetBytes(atom)))
                {
                    fs.Seek(-1, SeekOrigin.Current);
                    fs.WriteByte(0);
                }

                new Track(fs, ".mp4");
                IList <LogItem> logItems = log.GetAllItems(logLevel);
                Assert.IsTrue(logItems.Count > 0);
                bool found = false;
                foreach (LogItem l in logItems)
                {
                    if (l.Message.Contains(atomCaption + " atom could not be found"))
                    {
                        found = true;
                    }
                }
                Assert.IsTrue(found);
            }

            // Get rid of the working copy
            if (Settings.DeleteAfterSuccess)
            {
                File.Delete(testFileLocation);
            }
        }
예제 #5
0
        private void tagIO_RW_UpdatePadding(string resource, int paddingSize = 2048)
        {
            ATL.Settings.PaddingSize = paddingSize;
            try
            {
                ArrayLogger log              = new ArrayLogger();
                string      location         = TestUtils.GetResourceLocationRoot() + resource;
                string      testFileLocation = TestUtils.CopyAsTempTestFile(resource);
                Track       theTrack         = new Track(testFileLocation);

                string originalTitle = theTrack.Title;

                // Test the use of padding without padding option on

                // A1- Check that the resulting file (working copy that has been processed) keeps the same quantity of bytes when adding data
                theTrack.Title = originalTitle + "1234567890";
                theTrack.Save();

                // A11- File length should be the same
                FileInfo originalFileInfo = new FileInfo(location);
                FileInfo testFileInfo     = new FileInfo(testFileLocation);

                Assert.AreEqual(originalFileInfo.Length, testFileInfo.Length);

                // A12- No stream manipulation should have occurred
                IList <LogItem> logItems = log.GetAllItems(LV_DEBUG);
                foreach (LogItem item in logItems)
                {
                    if (item.Message.StartsWith("Disk stream operation : "))
                    {
                        Assert.Fail(item.Message);
                    }
                }

                // A2- Check that the resulting file (working copy that has been processed) keeps the same quantity of bytes when removing data
                theTrack.Title = originalTitle;
                theTrack.Save();

                // A21- File length should be the same
                originalFileInfo = new FileInfo(location);
                testFileInfo     = new FileInfo(testFileLocation);

                Assert.AreEqual(originalFileInfo.Length, testFileInfo.Length);

                // A22- No stream manipulation should have occurred
                logItems = log.GetAllItems(LV_DEBUG);
                foreach (LogItem item in logItems)
                {
                    if (item.Message.StartsWith("Disk stream operation : "))
                    {
                        Assert.Fail(item.Message);
                    }
                }

                // Get rid of the working copy
                if (Settings.DeleteAfterSuccess)
                {
                    File.Delete(testFileLocation);
                }
            }
            finally
            {
                ATL.Settings.PaddingSize = 2048;
            }
        }