public void SerializeProject()
        {
            IProject project = TestFramework.ProjectManager.CreateProject(ProjectPath, ProjectInvestigator, DateTime.Now, ProjectDescription);

            IDetector  systemDetector = TestFramework.DetectorFactory.ContainerDetectors.Single(x => x.Name == "MPEG-1/2 Systems");
            IDetector  videoDetector  = TestFramework.DetectorFactory.CodecDetectors.Single(x => x.Name == Mpeg2VideoDetector.DetectorName);
            IInputFile inputFile1     = project.AddFile(FileName1, new[] { systemDetector, videoDetector });
            IInputFile inputFile2     = project.AddFile(FileName2, new[] { videoDetector });

            IDataBlockBuilder dataBlockBuilder1 = TestFramework.CreateDataBlockBuilder();

            dataBlockBuilder1.DataFormat  = CodecID.Mpeg2System;
            dataBlockBuilder1.Detectors   = new[] { systemDetector };
            dataBlockBuilder1.InputFile   = inputFile1;
            dataBlockBuilder1.StartOffset = 0L;
            dataBlockBuilder1.EndOffset   = 20480L;
            dataBlockBuilder1.IsFullFile  = true;
            ICodecStreamBuilder codecStreamBuilder = dataBlockBuilder1.AddCodecStream();

            codecStreamBuilder.Name       = "Video Stream #1";
            codecStreamBuilder.DataFormat = CodecID.Mpeg2Video;
            codecStreamBuilder.Detector   = videoDetector;
            codecStreamBuilder.Data       = TestFramework.CreateDataPacket(inputFile1, 0L, 3033L);
            IDataBlock dataBlock1 = dataBlockBuilder1.Build();

            IDataBlockBuilder dataBlockBuilder2 = TestFramework.CreateDataBlockBuilder();

            dataBlockBuilder2.DataFormat  = CodecID.Mpeg2Video;
            dataBlockBuilder2.Detectors   = new[] { videoDetector };
            dataBlockBuilder2.InputFile   = inputFile1;
            dataBlockBuilder2.StartOffset = 130303L;
            dataBlockBuilder2.EndOffset   = 130327L;
            dataBlockBuilder2.IsFullFile  = false;
            IDataBlock dataBlock2 = dataBlockBuilder2.Build();

            IDataBlockBuilder dataBlockBuilder3 = TestFramework.CreateDataBlockBuilder();

            dataBlockBuilder3.DataFormat  = CodecID.Mpeg2Video;
            dataBlockBuilder3.Detectors   = new[] { videoDetector };
            dataBlockBuilder3.InputFile   = inputFile2;
            dataBlockBuilder3.StartOffset = 0L;
            dataBlockBuilder3.EndOffset   = FileLength2;
            dataBlockBuilder3.IsFullFile  = true;
            IDataBlock dataBlock3 = dataBlockBuilder3.Build();

            project.AddDataBlock(dataBlock1);
            project.AddDataBlock(dataBlock2);
            project.AddDataBlock(dataBlock3);
            project.SetMetadata(_fullMetadata);
//			project.SetVisibleColumns(systemDetector, TwoColumns);

            IProject deserializedProject;

            using (FileStream fileStream = new FileStream(_project.FileName, FileMode.Create))
            {
                TestFramework.CreateXmlObjectSerializer().WriteObject(fileStream, project);
            }
            using (FileStream fileStream = new FileStream(ProjectPath, FileMode.Open))
            {
                deserializedProject = TestFramework.CreateXmlObjectSerializer().ReadObject(fileStream) as IProject;
            }

            IList <IInputFile> inputFiles = deserializedProject.GetInputFiles();

            Assert.AreEqual(2, inputFiles.Count, "Serialization, input files (2 files)");
            AreEqual(inputFile1, inputFiles[0], "1");
            AreEqual(inputFile2, inputFiles[1], "2");

            IList <IDataBlock> dataBlocks = deserializedProject.GetDataBlocks(inputFiles[0]);

            Assert.AreEqual(2, dataBlocks.Count, "Serialization, data blocks (file 1, 2 blocks)");
            AreEqual(dataBlock1, dataBlocks[0], "1", "1");
            AreEqual(dataBlock2, dataBlocks[1], "1", "2");
            dataBlocks = deserializedProject.GetDataBlocks(inputFiles[1]);
            Assert.AreEqual(1, dataBlocks.Count, "Serialization, data blocks (file 2, 1 block)");
            AreEqual(dataBlock3, dataBlocks[0], "2", "1");

            IDictionary <ProjectMetadataKey, string> metadata = deserializedProject.GetMetadata();

            Assert.AreEqual(5, metadata.Count, "Serialization, metadata (5 entries)");
            Assert.IsTrue(metadata.ContainsKey(ProjectMetadataKey.FileVersion), "Serialization, metadata (FileVersion)");
            Assert.AreEqual("1.0.0.4", metadata[ProjectMetadataKey.FileVersion], "Serialization, metadata (FileVersion)");
            Assert.IsTrue(metadata.ContainsKey(ProjectMetadataKey.ProjectDescription), "Serialization, metadata (ProjectDescription)");
            Assert.AreEqual(ProjectDescription, metadata[ProjectMetadataKey.ProjectDescription], "Serialization, metadata (ProjectDescription)");
            Assert.IsTrue(metadata.ContainsKey(ProjectMetadataKey.InvestigatorName), "Serialization, metadata (InvestigatorName)");
            Assert.AreEqual(ProjectInvestigator, metadata[ProjectMetadataKey.InvestigatorName], "Serialization, metadata (InvestigatorName)");
            Assert.IsTrue(metadata.ContainsKey(ProjectMetadataKey.DateCreated), "Serialization, metadata (DateCreated)");
            Assert.AreEqual(ProjectCreationDate, metadata[ProjectMetadataKey.DateCreated], "Serialization, metadata (DateCreated)");
            Assert.IsTrue(metadata.ContainsKey(ProjectMetadataKey.DateLastModified), "Serialization, metadata (DateLastModified)");
            Assert.AreEqual(ProjectModificationDate, metadata[ProjectMetadataKey.DateLastModified], "Serialization, metadata (DateLastModified)");

            //IList<IColumnInfo> visibleColumns = deserializedProject.GetVisibleColumns(systemDetector);
            //Assert.AreEqual(2, visibleColumns.Count, "Serialization, visible columns (2 columns)");
            //Assert.IsTrue(visibleColumns.Contains(_columnInfo1), "Serialization, visible columns (column 1)");
            //Assert.IsTrue(visibleColumns.Contains(_columnInfo2), "Serialization, visible columns (column 2)");

            TestFramework.ProjectManager.CloseProject(project);
        }
예제 #2
0
 public void SetUp()
 {
     _ffmpegManager = new FFmpegManager(TestFramework.CreateFrameConverter(), null);
 }
        public void TestGetDataPacketRandom()
        {
            IDataPacket dataPacket = _dataReader.GetDataPacket(30, 20);

            Assert.IsTrue(dataPacket.Equals(TestFramework.CreateDataPacket(InputFile, 40, 20)), "GetDataPacket() for random, unfragmented packet");
        }
 public void TestConstructorInvalidDataReader()
 {
     using (new FragmentedDataReader(TestFramework.CreateDataPacket(InputFile, 0, 100), _dataReaderPoolMock))
     {
     }
 }
 public void TestConstructorInputFileMismatch()
 {
     using (new FragmentedDataReader(TestFramework.CreateDataPacket(TestFramework.CreateInputFile(DataFileNameCopy), 0, 100), _dataReaderPoolMock))
     {
     }
 }
 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);
 }