private void Initialize(Stream stream) { ////Contract.Requires<ArgumentNullException>(stream != null, "stream cannot be null"); ////Contract.Requires<Exception>(stream.CanRead == true, "cannot read stream"); this.stream = stream; binaryReader = new BinaryReader(stream); Header = SectionHeader.Parse(binaryReader); BasePosition = binaryReader.BaseStream.Position; Rewind(); }
public static void SectionHeader_ConvertToByte_Test() { SectionHeader pre = SectionHeader.CreateEmptyHeader(false, false); using (MemoryStream stream = new MemoryStream(pre.ConvertToByte())) { using (BinaryReader br = new BinaryReader(stream)) { SectionHeader post = SectionHeader.Parse(br); Assert.AreEqual(pre.MagicNumber, post.MagicNumber); Assert.AreEqual(pre.ReverseByteOrder, post.ReverseByteOrder); Assert.AreEqual(pre.MajorVersion, post.MajorVersion); Assert.AreEqual(pre.MinorVersion, post.MinorVersion); Assert.AreEqual(pre.LinkType, post.LinkType); Assert.AreEqual(pre.MaximumCaptureLength, post.MaximumCaptureLength); Assert.AreEqual(pre.NanoSecondResolution, post.NanoSecondResolution); Assert.AreEqual(pre.SignificantFigures, post.SignificantFigures); Assert.AreEqual(pre.TimezoneOffset, post.TimezoneOffset); } } }