public async Task Handle_InitializeMessage_True() { // arrange (WebSocketContext context, WebSocketMock socket) = WebSocketContextHelper.Create(); var handler = new ConnectionInitializeHandler(); var message = new GenericOperationMessage { Type = MessageTypes.Connection.Initialize }; // act await handler.HandleAsync( context, message, CancellationToken.None); // assert Assert.Collection(socket.Outgoing, t => { Assert.Equal(MessageTypes.Connection.Accept, t.Type); }, t => { Assert.Equal(MessageTypes.Connection.KeepAlive, t.Type); }); }
public async Task Can_AcceptMessage_False() { // arrange var webSocketContext = new InMemoryWebSocketContext(); var handler = new ConnectionInitializeHandler(); var message = new GenericOperationMessage { Type = MessageTypes.Connection.Initialize }; // act await handler.HandleAsync( webSocketContext, message, CancellationToken.None); // assert Assert.Collection(webSocketContext.Outgoing, t => { Assert.Equal(MessageTypes.Connection.Accept, t.Type); }, t => { Assert.Equal(MessageTypes.Connection.KeepAlive, t.Type); }); }
public void CanHandle_InitializeMessage_True() { // arrange var handler = new ConnectionInitializeHandler(); var message = new GenericOperationMessage { Type = MessageTypes.Connection.Initialize }; // act bool result = handler.CanHandle(message); // assert Assert.True(result); }