public async Task ShouldUnFrameMessage(string str, ByteOrder endianness)
        {
            var input = ByteString.FromString(str);

            var output = (await Source.Single(input).Via(StreamTransportFlows.Encode(byteOrder: endianness))
                          .Via(StreamTransportFlows.Decode(byteOrder: endianness))
                          .RunAggregate(new List <ByteString>(), (list, s) =>
            {
                list.Add(s);
                return(list);
            }, Sys.Materializer())).Single();

            // length should be same
            output.Count.Should().Be(input.Count);
            output.Should().BeEquivalentTo(input);
        }
        public async Task ShouldFrameMessage(string str, ByteOrder endianness)
        {
            var input = ByteString.FromString(str);

            var output = (await Source.Single(input).Via(StreamTransportFlows.Encode(byteOrder: endianness))
                          .RunAggregate(new List <ByteString>(), (list, s) =>
            {
                list.Add(s);
                return(list);
            }, Sys.Materializer())).Single();

            // length should be input + 4 byte header
            output.Count.Should().Be(input.Count + 4);
            var measuredLength = BitConverter.ToInt32(output.Slice(0, 4).ToArray(), 0);

            if (endianness == ByteOrder.BigEndian)
            {
                measuredLength = StreamTransportFlows.SwapInt(measuredLength);
            }
            measuredLength.Should().Be(input.Count);
        }