private void Initialize(Stream stream, SectionHeader header)
 {
     // //Contract.Requires<ArgumentNullException>(stream != null, "stream cannot be null");
     //  //Contract.Requires<Exception>(stream.CanWrite == true, "Cannot write to stream");
     // //Contract.Requires<ArgumentNullException>(header != null, "header cannot be null");
     this.header  = header;
     this.stream  = stream;
     binaryWriter = new BinaryWriter(stream);
     binaryWriter.Write(header.ConvertToByte());
 }
Exemple #2
0
 private void Initialize(Stream stream, SectionHeader header)
 {                     
     Contract.Requires<ArgumentNullException>(stream != null, "stream cannot be null");
     Contract.Requires<Exception>(stream.CanWrite == true, "Cannot write to stream");
     Contract.Requires<ArgumentNullException>(header != null, "header cannot be null");
     this.header = header;              
     this.stream = stream;
     binaryWriter = new BinaryWriter(stream);
     binaryWriter.Write(header.ConvertToByte());            
 }
Exemple #3
0
            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);
                    }
                }
            }