public void Ctor_Streams() { Assert.Throws<ArgumentException>(() => new PEReader(new CustomAccessMemoryStream(canRead: false, canSeek: false, canWrite: false))); Assert.Throws<ArgumentException>(() => new PEReader(new CustomAccessMemoryStream(canRead: true, canSeek: false, canWrite: false))); var s = new CustomAccessMemoryStream(canRead: true, canSeek: true, canWrite: false); new PEReader(s); new PEReader(s, PEStreamOptions.Default, 0); Assert.Throws<ArgumentOutOfRangeException>(() => new PEReader(s, PEStreamOptions.Default, -1)); Assert.Throws<ArgumentOutOfRangeException>(() => new PEReader(s, PEStreamOptions.Default, 1)); }
public void Ctor_Streams() { Assert.Throws<ArgumentException>(() => new PEHeaders(new CustomAccessMemoryStream(canRead: false, canSeek: false, canWrite: false))); Assert.Throws<ArgumentException>(() => new PEHeaders(new CustomAccessMemoryStream(canRead: true, canSeek: false, canWrite: false))); var s = new CustomAccessMemoryStream(canRead: true, canSeek: true, canWrite: false, buffer: Misc.Members); s.Position = 0; new PEHeaders(s); s.Position = 0; new PEHeaders(s, 0); s.Position = 0; Assert.Throws<ArgumentOutOfRangeException>(() => new PEHeaders(s, -1)); Assert.Equal(0, s.Position); Assert.Throws<BadImageFormatException>(() => new PEHeaders(s, 1)); Assert.Equal(0, s.Position); }