public async Task should_receive_messages()
        {
            /* Given */
            var log        = Substitute.For <ILogger <GraphQLEndPoint <TestSchema> > >();
            var handler    = Substitute.For <ISubscriptionProtocolHandler <TestSchema> >();
            var connection = Substitute.For <IConnectionContext>();

            connection.ConnectionId.Returns("1");

            var sut = new GraphQLEndPoint <TestSchema>(handler, log);

            /* When */
            await sut.OnConnectedAsync(connection).ConfigureAwait(false);

            /* Then */
            await connection.Reader.Received().ReadMessageAsync <OperationMessage>().ConfigureAwait(false);
        }
        public async Task should_connect()
        {
            /* Given */
            var log        = Substitute.For <ILogger <GraphQLEndPoint <TestSchema> > >();
            var handler    = Substitute.For <ISubscriptionProtocolHandler <TestSchema> >();
            var connection = Substitute.For <IConnectionContext>();

            connection.ConnectionId.Returns("1");

            var sut = new GraphQLEndPoint <TestSchema>(handler, log);

            /* When */
            await sut.OnConnectedAsync(connection).ConfigureAwait(false);

            /* Then */
            Assert.True(sut.Connections.ContainsKey(connection.ConnectionId));
        }
        public async Task should_handle_received_messages()
        {
            /* Given */
            var log        = Substitute.For <ILogger <GraphQLEndPoint <TestSchema> > >();
            var handler    = Substitute.For <ISubscriptionProtocolHandler <TestSchema> >();
            var connection = Substitute.For <IConnectionContext>();

            connection.ConnectionId.Returns("1");

            var message = new OperationMessage();

            connection.Reader.ReadMessageAsync <OperationMessage>().Returns(message)
            .AndDoes(ci => connection.CloseStatus.Returns(WebSocketCloseStatus.NormalClosure));
            var sut = new GraphQLEndPoint <TestSchema>(handler, log);

            /* When */
            await sut.OnConnectedAsync(connection).ConfigureAwait(false);

            /* Then */
            await handler.Received().HandleMessageAsync(
                Arg.Is <OperationMessageContext>(context => context.ConnectionId == connection.ConnectionId &&
                                                 context.Op == message)).ConfigureAwait(false);
        }