public void ReadFixedZeroFilledString_StreamTooShort() { var stream = new MemoryStream(); var reader = new BinaryStreamReader(stream, new byte[20]); reader.ReadFixedZeroFilledAsciiString(8); }
public void ReadFixedZeroFilledString_A() { var reader = new BinaryStreamReader(new MemoryStream(new byte[] { 65 }), new byte[20]); string str = reader.ReadFixedZeroFilledAsciiString(1); Assert.AreEqual("A", str); }
public void ReadFixedZeroFilledString_0IsEmpty() { var reader = new BinaryStreamReader(new MemoryStream(), new byte[20]); string str = reader.ReadFixedZeroFilledAsciiString(0); Assert.AreEqual("", str); }
public void ShortThenExtend_ReadFixedZeroFilledString_StreamTooShort() { var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCD"), 1); var reader = new BinaryStreamReader(stream, new byte[20]); reader.ReadByte(); reader.ReadFixedZeroFilledAsciiString(20); }
public void ShortThenExtend_ReadFixedZeroFilledString_Alphabet() { var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1); var reader = new BinaryStreamReader(stream, new byte[20]); reader.ReadByte(); string str = reader.ReadFixedZeroFilledAsciiString(26); Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", str); }
static void ReadSectionHeader(BinaryStreamReader reader, SectionHeader section) { section.Name = reader.ReadFixedZeroFilledAsciiString(SectionHeader.MaximumNameSize); section.VirtualSize = reader.ReadUInt32(); section.VirtualAddress = reader.ReadUInt32(); section.SizeOfRawData = reader.ReadUInt32(); section.PointerToRawData = reader.ReadUInt32(); section.PointerToRelocations = reader.ReadUInt32(); section.PointerToLinenumbers = reader.ReadUInt32(); section.NumberOfRelocations = reader.ReadUInt16(); section.NumberOfLinenumbers = reader.ReadUInt16(); section.Characteristics = (SectionCharacteristics)reader.ReadUInt32(); }
public void ReadFixedZeroFilledString_Negative() { var reader = new BinaryStreamReader(new MemoryStream(), new byte[20]); string str = reader.ReadFixedZeroFilledAsciiString(-1); }
public void ReadFixedZeroFilledString_FilledWithZero() { var reader = new BinaryStreamReader(new MemoryStream(new byte[1]), new byte[20]); string str = reader.ReadFixedZeroFilledAsciiString(1); Assert.AreEqual("", str); }