public async Task CloseNoopsIfInTerminalState(WebSocketState state) { var webSocket = new Mock <WebSocket>(); var webSocketHandler = new WebSocketHandler(64 * 1024); webSocket.Setup(m => m.State).Returns(state); webSocketHandler.WebSocket = webSocket.Object; await webSocketHandler.CloseAsync(); webSocket.Verify(m => m.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None), Times.Never()); }