public void close_external_Stream() { 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(); }
public void dont_close_our_internal_stream() { 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(); }