Пример #1
0
        public void DocType_Equals()
        {
            var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            Assert.AreEqual(docType, reader.DocType);
        }
Пример #2
0
        public void JumpToElementAt()
        {
            var dataSrc = new EBMLFixedByteArrayDataSource(new byte[] { 0x1A, 0x45, 0xDF, 0xA3, 0x80 });
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            var elemInfo = reader.Next();
            using(reader.EnterElement(elemInfo)) {
                reader.Next();
            }

            Assert.IsTrue(reader.JumpToElementAt(0).IdPos == elemInfo.IdPos, "Basestream was not reset");
        }
Пример #3
0
        public void ParseMatroskaTestSuite_ParseFile(string filePath)
        {
            Stream src;
            try {
                src = File.OpenRead(filePath);
                //src = File.OpenRead(@"C:\Users\Arokh\Projects\Visual Studio 2012\Projects\CSEBML\CSEBMLTest\bin\Release\TestFiles\MatroskaTestSuite\test7.mkv");
            } catch(Exception) {
                Assert.Inconclusive("Couldn't open Matroska Test File ({0})", filePath);
                return;
            }

            var ebmlSrc = new EBMLStreamDataSource(src);
            var matroskaDoc = new MatroskaDocType(CSEBML.DocTypes.Matroska.MatroskaVersion.V3);
            var ebmlReader = new EBMLReader(ebmlSrc, matroskaDoc);

            Action<bool> recurse = readValues => {
                try {
                    ebmlReader.Reset();
                    Recurse(ebmlReader, readValues);
                } catch(Exception ex) {
                    ex.Data.Add("ReadValues", readValues);
                    throw;
                }
            };

            recurse(true);
            recurse(false);
        }
Пример #4
0
 private static void Recurse(EBMLReader reader, bool readValues)
 {
     ElementInfo elemInfo;
     while((elemInfo = reader.Next()) != null) {
         if(elemInfo.DocElement.Type == EBMLElementType.Master) {
             using(reader.EnterElement(elemInfo)) {
                 Recurse(reader, readValues);
             }
         } else if(readValues) {
             var obj = reader.RetrieveValue(elemInfo);
         }
     }
 }
Пример #5
0
        public void RetrieveValue_ZeroLength()
        {
            var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            reader.RetrieveValue(new ElementInfo(EBMLDocElement.Unknown, 0, 0, 0, 0));
            reader.RetrieveValue(new ElementInfo(EBMLDocElement.Unknown, 1, 1, 1, 0));
        }
Пример #6
0
 public void RetrieveValue_WrongPosition()
 {
     var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
     var docType = new EBMLDocType();
     var reader = new EBMLReader(dataSrc, docType);
     reader.RetrieveValue(new ElementInfo(EBMLDocElement.Unknown, 1, 2, 3, 1));
 }
Пример #7
0
 public void RetrieveValue_NullArgument()
 {
     var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
     var docType = new EBMLDocType();
     var reader = new EBMLReader(dataSrc, docType);
     reader.RetrieveValue(null);
 }
Пример #8
0
        public void Reset()
        {
            var dataSrc = new EBMLFixedByteArrayDataSource(new byte[] { 0x1A, 0x45, 0xDF, 0xA3, 0x80 });
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            var elemInfo = reader.Next();
            using(reader.EnterElement(elemInfo)) {
                elemInfo = reader.Next();
            }

            reader.Reset();
            Assert.IsTrue(reader.BaseStream.Position == 0, "Bastream was not reset");
        }