private void VerifyReadWriteByteArray(PackStreamWriterMachine machine, int length)
        {
            var array = new byte[length];

            machine.Reset();
            machine.Writer().Write(array);

            var readerMachine = CreateReaderMachine(machine.GetOutput());
            var packedType    = readerMachine.Reader().PeekNextType();
            var packedValue   = readerMachine.Reader().ReadBytes();

            // Then
            packedType.Should().Be(PackStream.PackType.Bytes);
            packedValue.Should().Equal(array);
        }
Esempio n. 2
0
            public void ShouldNotReadByteArray()
            {
                // Given (byte array supporting writer machine)
                var writerMachine = new PackStreamWriterMachine(s => new PackStreamWriter(s, null));

                var writer = writerMachine.Writer();

                writer.Write(Encoding.UTF8.GetBytes("ABCDEFGHIJ"));

                // When
                var readerMachine = CreateReaderMachine(writerMachine.GetOutput());
                var reader        = readerMachine.Reader();

                // Then
                var ex = Record.Exception(() => reader.Read());

                ex.Should().NotBeNull();
                ex.Should().BeOfType <ProtocolException>();
            }