Exemplo n.º 1
0
        public void StreamHelpers_EmptyArray()
        {
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadSByte(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadByte(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadInt16(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadUInt16(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadInt32(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadUInt32(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadInt64(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadUInt64(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadSingle(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadDouble(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadDecimal(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadChar(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadBoolean(new MemoryStream()));
            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadGuid(new MemoryStream()));

            using var stream = new MemoryStream();

            stream.WriteUInt32Compact(42u);
            stream.Position = 0;

            Assert.ThrowsException <EndOfStreamException>(() => StreamHelpers.ReadString(stream));
        }