예제 #1
0
        public void TestWriteDataBlockFile1()
        {
            string outputFilePath = string.Format("{0}{1}", _testDataFile1, @"_TestDefraser.MockDetectorSave_0000000000000000-0000000000000033.dat");

            try
            {
                IInputFile         inputFile  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile1);
                IList <IDataBlock> dataBlocks = _project1.GetDataBlocks(inputFile);
                TestFramework.SaveAsSeparateFiles(new List <object> {
                    dataBlocks[0]
                }, TestFilesPath);
                byte[] contents = new byte[51];
                Array.Copy(_fullFile1, contents, 51);
                foreach (FileInfo fi in new DirectoryInfo(TestFilesPath).GetFiles())
                {
                    Console.WriteLine(fi);
                }
                Util.AssertArrayEqualsFile(contents, outputFilePath);
            }
            finally
            {
                if (File.Exists(outputFilePath))
                {
                    File.Delete(outputFilePath);
                }
            }
        }
        private void ScanAndSaveAsSeparateFiles(KeyValuePair <string, string> systemConfiguration, KeyValuePair <string, string> videoConfiguration)
        {
            DeleteSavedFiles();

            IProject projectIssue2490 = TestFramework.ProjectManager.CreateProject(FileNameProjectIssue2490, "S. Holmes", DateTime.Now, "Scan file 1");

            // Locate detectors (and change configuration)
            TestFramework.DetectorFactory.Initialize(".");

            IDetector systemDetector = Util.FindDetector(TestFramework.DetectorFactory.ContainerDetectors, "MPEG-1/2 Systems");
            IDetector videoDetector  = Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, Mpeg2VideoDetector.DetectorName);

            if (!string.IsNullOrEmpty(systemConfiguration.Key))
            {
                systemDetector.SetConfigurationItem(systemConfiguration.Key, systemConfiguration.Value);
            }
            if (!string.IsNullOrEmpty(videoConfiguration.Key))
            {
                videoDetector.SetConfigurationItem(videoConfiguration.Key, videoConfiguration.Value);
            }

            IDetector[] containerDetectors = new IDetector[] { systemDetector };
            IDetector[] codecDetectors     = new IDetector[] { videoDetector };

            List <IDetector> detectors = new List <IDetector>();

            detectors.AddRange(containerDetectors);
            detectors.AddRange(codecDetectors);

            // Scan test file
            IInputFile fileIssue2490 = TestFramework.DetectData(containerDetectors, codecDetectors, projectIssue2490, FileNameIssue2490);

            if (!string.IsNullOrEmpty(systemConfiguration.Key))
            {
                systemDetector.ResetConfigurationItem(systemConfiguration.Key);
            }
            if (!string.IsNullOrEmpty(videoConfiguration.Key))
            {
                videoDetector.ResetConfigurationItem(videoConfiguration.Key);
            }

            TestFramework.SaveAsSeparateFiles(new List <object> {
                fileIssue2490
            }, ".");

            if (projectIssue2490 != null)
            {
                TestFramework.ProjectManager.CloseProject(projectIssue2490);
                projectIssue2490 = null;
            }
        }
예제 #3
0
        public void TestWriteDataBlockFile2()
        {
            string outputFilePath = string.Format("{0}{1}", _testDataFile2, @"_TestDefraser.MockDetectorSave_0000000000000000-00000000000000FF.dat");

            try
            {
                IInputFile         inputFile  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile2);
                IList <IDataBlock> dataBlocks = _project1.GetDataBlocks(inputFile);
                TestFramework.SaveAsSeparateFiles(new List <object> {
                    dataBlocks[0]
                }, TestFilesPath);
                byte[] contents = new byte[255];
                Array.Copy(_fullFile2, contents, 255);
                Util.AssertArrayEqualsFile(contents, outputFilePath);
            }
            finally
            {
                if (File.Exists(outputFilePath))
                {
                    File.Delete(outputFilePath);
                }
            }
        }