Clear() public méthode

Remove everything used for the last message
public Clear ( ) : void
Résultat void
        public void can_clear_even_without_shit_being_used()
        {
            var serializer = new StringSerializer();
            var slice = new BufferSlice(new byte[65535], 0, 65535);
            var msg = "Hello world";
            var buffer = new SocketBufferFake();

            var sut = new MicroMessageEncoder(serializer, slice);
            sut.Clear();
            sut.Prepare(msg);
            sut.Send(buffer);

            var field = sut.GetType().GetField("_bodyStream", BindingFlags.Instance | BindingFlags.NonPublic);
            ((Stream)field.GetValue(sut)).CanWrite.Should().BeTrue();
        }
        public void dont_close_our_internal_stream_as_we_reuse_it()
        {
            var serializer = new StringSerializer();
            var slice = new BufferSlice(new byte[65535], 0, 65535);
            var msg = "Hello world";
            var buffer = new SocketBufferFake();

            var sut = new MicroMessageEncoder(serializer, slice);
            sut.Prepare(msg);
            sut.Send(buffer);
            sut.Clear();

            var field = sut.GetType().GetField("_bodyStream", BindingFlags.Instance | BindingFlags.NonPublic);
            ((Stream) field.GetValue(sut)).CanWrite.Should().BeTrue();
        }
        public void close_external_Stream_as_we_take_over_ownership_from_the_dev()
        {
            var serializer = new StringSerializer();
            var slice = new BufferSlice(new byte[65535], 0, 65535);
            var msg = new MemoryStream();
            var text = Encoding.ASCII.GetBytes("Hello world");
            msg.Write(text, 0, text.Length);
            msg.Position = 0;
            var buffer = new SocketBufferFake();

            var sut = new MicroMessageEncoder(serializer, slice);
            sut.Prepare(msg);
            sut.Send(buffer);
            sut.Clear();

            var field = sut.GetType().GetField("_bodyStream", BindingFlags.Instance | BindingFlags.NonPublic);
            if (field == null) throw new ArgumentNullException("field");
            var value = ((Stream)field.GetValue(sut));
            value.Should().BeNull();
        }