public async Task WebSocketServer_Connects() { var sock = new FauxSock(); var writer = new WebSocketServer(sock, new StreamingRequestHandler(new MockBot(), new BotFrameworkHttpAdapter(), sock)); writer.StartAsync(); Assert.True(writer.IsConnected); }
public async Task WebSocketServer_Connects() { var sock = new FauxSock(); var writer = new WebSocketServer(sock, new StreamingRequestHandler(new MockBot(), new BotFrameworkHttpAdapter(), sock)); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed writer.StartAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Assert.True(writer.IsConnected); }
public void CanBeConstructedWithAWebSocket(FauxSock socket, string audience) { // Arrange // Act var handler = new StreamingRequestHandler(new MockBot(), new BotFrameworkHttpAdapter(), socket, audience); // Assert Assert.NotNull(handler); Assert.Equal(audience, handler.Audience); }
public async Task WebSocketTransport_SetsState() { var sock = new FauxSock(); sock.RealState = WebSocketState.Open; var transport = new WebSocketTransport(sock); transport.Close(); transport.Dispose(); Assert.Equal(WebSocketState.Closed, sock.RealState); }
public async Task WebSocketTransport_Connects() { var sock = new FauxSock(); sock.RealState = WebSocketState.Open; var transport = new WebSocketTransport(sock); Assert.True(transport.IsConnected); transport.Close(); transport.Dispose(); }
public async Task WebSocketTransport_CanReceive() { // Arrange var sock = new FauxSock(); sock.RealState = WebSocketState.Open; var transport = new WebSocketTransport(sock); byte[] message = Encoding.ASCII.GetBytes("This is a message."); // Act var received = await transport.ReceiveAsync(message, 0, message.Length); // Assert Assert.Equal(message.Length, received); }
public async Task WebSocketTransport_CanSend() { // Arrange var sock = new FauxSock(); sock.RealState = WebSocketState.Open; var transport = new WebSocketTransport(sock); var messageText = "This is a message."; byte[] message = Encoding.ASCII.GetBytes(messageText); // Act await transport.SendAsync(message, 0, message.Length); // Assert Assert.Equal(messageText, Encoding.UTF8.GetString(sock.SentArray)); }
public async Task WebSocketServer_Connects() { var requestHandlerMock = new Mock <RequestHandler>(); requestHandlerMock.Setup( rh => rh.ProcessRequestAsync(It.IsAny <ReceiveRequest>(), It.IsAny <ILogger <RequestHandler> >(), It.IsAny <object>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new StreamingResponse { StatusCode = 200 }); var sock = new FauxSock(); // Set the faux-socket state because otherwise the background task might check it and disconnected before this test completes sock.RealState = WebSocketState.Open; var writer = new WebSocketServer(sock, requestHandlerMock.Object); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed writer.StartAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Assert.True(writer.IsConnected); }