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); }
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"); }
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); }
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); } } }
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)); }
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)); }
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); }
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"); }