Example #1
0
        public void TestSaveRandomResultsMultiProject()
        {
            IInputFile         inputFile1  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile1);
            IInputFile         inputFile2  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile2);
            IInputFile         inputFile3  = Util.FindInputFile(_project2.GetInputFiles(), _testDataFile3);
            IList <IDataBlock> dataBlocks1 = _project1.GetDataBlocks(inputFile1);
            IList <IDataBlock> dataBlocks2 = _project1.GetDataBlocks(inputFile2);
            IList <IDataBlock> dataBlocks3 = _project2.GetDataBlocks(inputFile3);
            IResultNode        results12   = TestFramework.GetResults(dataBlocks1[2]);
            IResultNode        results20   = TestFramework.GetResults(dataBlocks2[0]);
            IResultNode        results30   = TestFramework.GetResults(dataBlocks3[0]);

            IResultNode[] results = new IResultNode[5];
            results[0] = results30.Children[4].ShallowCopy();
            results[1] = results20.Children[0].ShallowCopy();
            results[2] = results12.Children[0].ShallowCopy();
            results[3] = results30.Children[1].ShallowCopy();
            results[4] = results20.Children[0].ShallowCopy();
            TestFramework.WriteResults(results, _testOutputFile);
            byte[] contents = new byte[57];
            Array.Copy(_fullFile3, 60, contents, 0, 15);
            Array.Copy(_fullFile2, 0, contents, 15, 5);
            Array.Copy(_fullFile1, 102, contents, 20, 17);
            Array.Copy(_fullFile3, 15, contents, 37, 15);
            Array.Copy(_fullFile2, 0, contents, 52, 5);
            Util.AssertArrayEqualsFile(contents, _testOutputFile);
        }
Example #2
0
        public void TestWriteRandomResultsFile1()
        {
            IInputFile         inputFile  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile1);
            IList <IDataBlock> dataBlocks = _project1.GetDataBlocks(inputFile);
            IResultNode        results0   = TestFramework.GetResults(dataBlocks[0]);
            IResultNode        results1   = TestFramework.GetResults(dataBlocks[1]);
            IResultNode        results2   = TestFramework.GetResults(dataBlocks[2]);
            IResultNode        results3   = TestFramework.GetResults(dataBlocks[3]);
            IResultNode        results4   = TestFramework.GetResults(dataBlocks[4]);

            IResultNode[] results = new IResultNode[5];
            results[0] = results0.Children[0].ShallowCopy();
            results[1] = results2.Children[0].ShallowCopy();
            results[2] = results4.Children[0].ShallowCopy();
            results[3] = results3.Children[0].ShallowCopy();
            results[4] = results1.Children[0].ShallowCopy();
            TestFramework.WriteResults(results, _testOutputFile);
            byte[] contents = new byte[85];
            Array.Copy(_fullFile1, 0, contents, 0, 17);
            Array.Copy(_fullFile1, 102, contents, 17, 17);
            Array.Copy(_fullFile1, 204, contents, 34, 17);
            Array.Copy(_fullFile1, 153, contents, 51, 17);
            Array.Copy(_fullFile1, 51, contents, 68, 17);
            Util.AssertArrayEqualsFile(contents, _testOutputFile);
        }
        public void TestReaderGetResultsResultVerifyContents()
        {
            IList <IDataBlock> dataBlocks = _project.GetDataBlocks(_project.GetInputFiles()[0]);
            IResultNode        results    = TestFramework.GetResults(dataBlocks[0]);

            results = results.Children[0];
            Assert.AreEqual(255, results.Children[0].StartOffset, "Result.Offset");
            Assert.AreEqual(2, results.Children[0].Length, "Result.Length");
            Assert.AreEqual("correct type 2", results.Children[0].Name, "Result.Name");
            Assert.AreEqual(true, results.Children[0].Children != null && results.Children[0].Children.Count > 0, "Result.HasChildren");
            Assert.AreEqual(4, results.Children[0].Attributes.Count, "Result.Attributes.Count");
            Assert.AreEqual("type2 first", results.Children[0].Attributes[0].Value, "Result.Attributes[0]");

            results = results.Children[0];
            Assert.AreEqual(260, results.Children[0].StartOffset, "Result.Offset");
            Assert.AreEqual(3, results.Children[0].Length, "Result.Length");
            Assert.AreEqual("correct type 1", results.Children[0].Name, "Result.Name");
            Assert.AreEqual(false, results.Children[0].Children != null && results.Children[0].Children.Count > 0, "Result.HasChildren");
            Assert.AreEqual(2, results.Children[0].Attributes.Count, "Result.Attributes.Count");
            Assert.AreEqual("type1 first", results.Children[0].Attributes[0].Value, "Result.Attributes[0]");

            Assert.AreEqual(264, results.Children[1].StartOffset, "Result.Offset");
            Assert.AreEqual(4, results.Children[1].Length, "Result.Length");
            Assert.AreEqual("correct type 2", results.Children[1].Name, "Result.Name");
            Assert.AreEqual(false, results.Children[1].Children != null && results.Children[1].Children.Count > 0, "Result.HasChildren");
            Assert.AreEqual(4, results.Children[1].Attributes.Count, "Result.Attributes.Count");
            Assert.AreEqual("type2 unique second", results.Children[1].Attributes[1].Value, "Result.Attributes[1]");
        }
        public void TestReaderGetDataBlocksVerifyContents()
        {
            IInputFile         inputFile  = _project.GetInputFiles()[0];
            IList <IDataBlock> dataBlocks = _project.GetDataBlocks(inputFile);

            Assert.AreEqual(inputFile, dataBlocks[0].InputFile, "DataBlock.InputFile");
            Assert.AreEqual(0, dataBlocks[0].StartOffset, "DataBlock.StartOffset");
            Assert.AreEqual(268, dataBlocks[0].Length, "DataBlock.Length");
            Assert.AreEqual(false, dataBlocks[0].IsFullFile, "DataBlock.IsFullFile");
            IResultNode results = TestFramework.GetResults(dataBlocks[0]);

            Assert.AreEqual(1, results.Children[0].Length, "DataBlock.StartResult.Length");
            Assert.AreEqual("correct type 1", results.Children[0].Name, "DataBlock.StartResult.Name");
            Assert.AreEqual(true, results.Children[0].Children != null && results.Children[0].Children.Count > 0, "DataBlock.StartResult.HasChildren");
            Assert.AreEqual(2, results.Children[0].Attributes.Count, "DataBlock.StartResult.Attributes.Count");

            Assert.AreEqual(inputFile, dataBlocks[1].InputFile, "DataBlock.InputFile");
            Assert.AreEqual(517, dataBlocks[1].StartOffset, "DataBlock.StartOffset");
            Assert.AreEqual(1, dataBlocks[1].Length, "DataBlock.Length");
            Assert.AreEqual(true, dataBlocks[1].IsFullFile, "DataBlock.IsFullFile");
            results = TestFramework.GetResults(dataBlocks[1]);
            Assert.AreEqual(1, results.Children[0].Length, "DataBlock.StartResult.Length");
            Assert.AreEqual("correct type 1", results.Children[0].Name, "DataBlock.StartResult.Name");
            Assert.AreEqual(false, results.Children[0].Children != null && results.Children[0].Children.Count > 0, "DataBlock.StartResult.HasChildren");
            Assert.AreEqual(2, results.Children[0].Attributes.Count, "DataBlock.StartResult.Attributes.Count");
        }
Example #5
0
        internal static void TestLastHeader(IFragment fragment, Constraint name, Constraint offset, Constraint length)
        {
            IResultNode result = GetLastResultNode(TestFramework.GetResults(fragment));

            Assert.That(result.Name, name, "Name");
            Assert.That(result.StartOffset, offset, "Offset");
            Assert.That(result.Length, length, "Length");
        }
Example #6
0
        internal static void TestFirstHeader(IFragment fragment, Constraint name, Constraint offset, Constraint length)
        {
            IResultNode results = TestFramework.GetResults(fragment);

            Assert.That(results.Children[0].Name, name, "Name");
            Assert.That(results.Children[0].StartOffset, offset, "Offset");
            Assert.That(results.Children[0].Length, length, "Length");
        }
Example #7
0
        internal static void TestOneHeader(IFragment fragment, Constraint name, Constraint offset, Constraint length)
        {
            IResultNode results = TestFramework.GetResults(fragment);

            Assert.That(results.Children.Count, Is.EqualTo(1), "There should by only one child");             // assert that there is only one header
            Assert.That(results.Children[0].Name, name, "Name");
            Assert.That(results.Children[0].StartOffset, offset, "Offset");
            Assert.That(results.Children[0].Length, length, "Length");
        }
        public void TestReaderGetResultsDataBlockVerifyCount()
        {
            IList <IDataBlock> dataBlocks = _project.GetDataBlocks(_project.GetInputFiles()[0]);
            IResultNode        results    = TestFramework.GetResults(dataBlocks[0]);

            Assert.AreEqual(1, results.Children.Count, "Data block should contain a single top-level result.");
            results = TestFramework.GetResults(dataBlocks[1]);
            Assert.AreEqual(1, results.Children.Count, "Data block should contain a single top-level result.");
        }
Example #9
0
        public void TestWriteContiguousResultsFile2()
        {
            IInputFile         inputFile  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile2);
            IList <IDataBlock> dataBlocks = _project1.GetDataBlocks(inputFile);

            IResultNode[] results = (new List <IResultNode>(TestFramework.GetResults(dataBlocks[0]).Children)).ToArray();
            TestFramework.WriteResults(results, _testOutputFile);
            byte[] contents = new byte[255];
            Array.Copy(_fullFile2, contents, 255);
            Util.AssertArrayEqualsFile(contents, _testOutputFile);
        }
Example #10
0
        internal static void TestStream(IFragment detectable, Constraint dataFormat, Constraint length,
                                        Constraint isFragmented, Constraint fragmentedContrainer, Constraint fragmentedIndex,
                                        Constraint headerCount)
        {
            IResultNode results = TestFramework.GetResults(detectable);

            Assert.That(results.Children.Count, headerCount, "Number of headers");
            Assert.That(detectable.DataFormat, dataFormat, "Data format");
            Assert.That(detectable.Length, length, "Length");
            Assert.That(detectable.IsFragmented, isFragmented, "Is fragmented");
            Assert.That(detectable.FragmentContainer, fragmentedContrainer, "Fragment container");
            Assert.That(detectable.FragmentIndex, fragmentedIndex, "Fragment index");
        }
Example #11
0
        public void TestWriteResultFile1()
        {
            IInputFile         inputFile  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile1);
            IList <IDataBlock> dataBlocks = _project1.GetDataBlocks(inputFile);
            IResultNode        results    = TestFramework.GetResults(dataBlocks[1]);

            results = results.Children[0];
            IResultNode[] result = new IResultNode[1];
            result[0] = results.Children[0].ShallowCopy();
            TestFramework.WriteResults(result, _testOutputFile);
            byte[] contents = new byte[17];
            Array.Copy(_fullFile1, 4 * 17, contents, 0, 17);
            Util.AssertArrayEqualsFile(contents, _testOutputFile);
        }
        public void TestReaderGetResultsResultVerifyCount()
        {
            IList <IDataBlock> dataBlocks = _project.GetDataBlocks(_project.GetInputFiles()[0]);
            IResultNode        results    = TestFramework.GetResults(dataBlocks[0]);

            results = results.Children[0];
            Assert.AreEqual(1, results.Children.Count, "First result should have a single child result.");

            results = results.Children[0];
            Assert.AreEqual(2, results.Children.Count, "Second result should have two child results.");

            Assert.AreEqual(0, results.Children[0].Children.Count, "Third result should have no child results.");
            Assert.AreEqual(0, results.Children[1].Children.Count, "Fourth result should have no child results.");
        }
Example #13
0
        public void TestSaveRandomResultsMultiFile()
        {
            IInputFile         inputFile1  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile1);
            IInputFile         inputFile2  = Util.FindInputFile(_project1.GetInputFiles(), _testDataFile2);
            IList <IDataBlock> dataBlocks1 = _project1.GetDataBlocks(inputFile1);
            IList <IDataBlock> dataBlocks2 = _project1.GetDataBlocks(inputFile2);
            IResultNode        results11   = TestFramework.GetResults(dataBlocks1[1]);
            IResultNode        results13   = TestFramework.GetResults(dataBlocks1[3]);
            IResultNode        results20   = TestFramework.GetResults(dataBlocks2[0]);

            IResultNode[] results = new IResultNode[3];
            results[0] = results11.Children[0].ShallowCopy();
            results[1] = results20.Children[0].ShallowCopy();
            results[2] = results13.Children[0].ShallowCopy();
            TestFramework.WriteResults(results, _testOutputFile);
            byte[] contents = new byte[39];
            Array.Copy(_fullFile1, 51, contents, 0, 17);
            Array.Copy(_fullFile2, 0, contents, 17, 5);
            Array.Copy(_fullFile1, 153, contents, 22, 17);
            Util.AssertArrayEqualsFile(contents, _testOutputFile);
        }
Example #14
0
        private static Bitmap ScanFile(string filename, string codecDetectorName)
        {
            TestFramework.DetectorFactory.Initialize(".");

            IProject testProject = TestFramework.ProjectManager.CreateProject(FileNameTestProject, "S. Holmes", DateTime.Now, "File scan, used to test creating of thumbs.");

            IDetector          codecDetector = Util.FindDetector(TestFramework.DetectorFactory.CodecDetectors, codecDetectorName);
            IInputFile         testFile      = TestFramework.DetectData(codecDetector, testProject, filename);
            IList <IDataBlock> dataBlocks    = testProject.GetDataBlocks(testFile);
            IResultNode        resultNode    = TestFramework.GetResults(dataBlocks[0]);

            // Get the first I-frame from the video stream
            IResultNode keyFrameNode = FindKeyFrame(resultNode);

            Assert.IsNotNull(keyFrameNode, "Could not find any keyframe in " + Path.GetFileName(filename) + " using codec " + codecDetectorName + ". Please check decoder's unittests.");
            Bitmap bitmap = TestFFmpegSetup.FFmpegManager.FrameConvertor.FrameToBitmap(keyFrameNode);

            TestFramework.ProjectManager.CloseProject(testProject);
            File.Delete(FileNameTestProject);

            return(bitmap);
        }
 public void TestReaderGetResultsDataBlockUnknown()
 {
     IDataPacket data      = TestFramework.CreateDataPacket(TestFramework.CreateInputFile("ja"), 31337, 1);
     IDataBlock  dataBlock = TestFramework.CreateDataBlock(TestFramework.DetectorFactory.Detectors[0], data, false, null);
     IResultNode results   = TestFramework.GetResults(dataBlock);                // TODO: _project??
 }
 public void TestReaderGetResultsDataBlockInvalid()
 {
     IResultNode results = TestFramework.GetResults((IDataBlock)null);
 }