예제 #1
0
        public void CanHandle_AcceptMessage_False()
        {
            // arrange
            var handler = new ConnectionTerminateHandler();
            var message = new GenericOperationMessage
            {
                Type = MessageTypes.Connection.Accept
            };

            // act
            bool result = handler.CanHandle(message);

            // assert
            Assert.False(result);
        }
예제 #2
0
        public async Task Handle_TerminateMessage_True()
        {
            // arrange
            (WebSocketContext context, WebSocketMock socket) =
                WebSocketContextHelper.Create();
            var handler = new ConnectionTerminateHandler();
            var message = new GenericOperationMessage
            {
                Type = MessageTypes.Connection.Terminate
            };

            // act
            await handler.HandleAsync(
                context,
                message,
                CancellationToken.None);

            // assert
            Assert.True(socket.Closed);
        }
        public async Task Can_AcceptMessage_False()
        {
            // arrange
            var webSocketContext = new InMemoryWebSocketContext();

            var handler = new ConnectionTerminateHandler();

            var message = new GenericOperationMessage
            {
                Type = MessageTypes.Connection.Terminate
            };

            // act
            await handler.HandleAsync(
                webSocketContext,
                message,
                CancellationToken.None);

            // assert
            Assert.True(webSocketContext.IsDisposed);
        }