public void WriteTwoSequentialMessages() { var handshake = this.GenerateSimpleHandshake(); using (var connectionInput = new MemoryStream()) using (var connectionOutput = new MemoryStream()) using (var connection = new DummyNetworkConnection(connectionInput, connectionOutput)) using (var ws = new WebSocketRfc6455(connection, this.options, handshake.Request, handshake.Response, handshake.NegotiatedMessageExtensions)) { using (var writer = ws.CreateMessageWriter(WebSocketMessageType.Text)) { } using (var writer = ws.CreateMessageWriter(WebSocketMessageType.Text)) { } } }
public void With_WebSocket_CanWriteTwoSequentialMessages() { var handshake = GenerateSimpleHandshake(); using (var ms = new MemoryStream()) using (WebSocket ws = new WebSocketRfc6455(ms, new WebSocketListenerOptions() { PingTimeout = Timeout.InfiniteTimeSpan }, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2), handshake.Request, handshake.Response, handshake.NegotiatedMessageExtensions)) { using (var writer = ws.CreateMessageWriter(WebSocketMessageType.Text)) { } using (var writer = ws.CreateMessageWriter(WebSocketMessageType.Text)) { } } }
public void FailDoubleMessageWrite() { var handshake = this.GenerateSimpleHandshake(); Assert.Throws <WebSocketException>(() => { using (var connectionInput = new MemoryStream()) using (var connectionOutput = new MemoryStream()) using (var connection = new DummyNetworkConnection(connectionInput, connectionOutput)) using (var ws = new WebSocketRfc6455(connection, this.options, handshake.Request, handshake.Response, handshake.NegotiatedMessageExtensions)) { var writer = ws.CreateMessageWriter(WebSocketMessageType.Text); writer = ws.CreateMessageWriter(WebSocketMessageType.Text); } }); }
public void With_WebSocket_FailsWithDoubleMessageWrite() { Assert.Throws <WebSocketException>(() => { var handshake = GenerateSimpleHandshake(); using (var ms = new MemoryStream()) using ( WebSocket ws = new WebSocketRfc6455(ms, new WebSocketListenerOptions() { PingTimeout = Timeout.InfiniteTimeSpan }, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2), handshake.Request, handshake.Response, handshake.NegotiatedMessageExtensions)) { var writer = ws.CreateMessageWriter(WebSocketMessageType.Text); writer = ws.CreateMessageWriter(WebSocketMessageType.Text); } }); }