Beispiel #1
0
        public override void StreamFrom(Stream _stream)
        {
            byte b65 = (byte)_stream.ReadByte();
            byte b26 = (byte)_stream.ReadByte();

            PRA  = (byte)_stream.ReadByte();
            PRB  = (byte)_stream.ReadByte();
            DDRA = (byte)_stream.ReadByte();
            DDRB = (byte)_stream.ReadByte();
            SDR  = (byte)_stream.ReadByte();
            CRA  = (byte)_stream.ReadByte();
            CRB  = (byte)_stream.ReadByte();

            TimerA         = StreamHelpers.ReadInt16(_stream);
            TimerA_LatchLO = (byte)_stream.ReadByte();
            TimerA_LatchHI = (byte)_stream.ReadByte();

            TimerB         = StreamHelpers.ReadInt16(_stream);
            TimerB_LatchLO = (byte)_stream.ReadByte();
            TimerB_LatchHI = (byte)_stream.ReadByte();

            INT_DATA = (byte)_stream.ReadByte();
            INT_MASK = (byte)_stream.ReadByte();

            FlagPIN = StreamHelpers.ReadBool(_stream);
        }
        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));
        }