示例#1
0
        public void CanHandle_DataStartMessage_True()
        {
            // arrange
            var errorHandler          = new Mock <IErrorHandler>();
            var interceptor           = new DefaultSocketSessionInterceptor();
            IRequestExecutor executor = SchemaBuilder.New()
                                        .AddStarWarsTypes()
                                        .Create()
                                        .MakeExecutable();
            DocumentNode query   = Utf8GraphQLParser.Parse("{ hero { name } }");
            var          handler = new DataStartMessageHandler(
                executor,
                interceptor,
                errorHandler.Object,
                new NoopExecutionDiagnosticEvents());

            var message = new DataStartMessage(
                "123",
                new GraphQLRequest(query));

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

            // assert
            Assert.True(result);
        }
        public void CanHandle_KeepAliveMessage_False()
        {
            // arrange
            var interceptor           = new DefaultSocketSessionInterceptor();
            IRequestExecutor executor = SchemaBuilder.New()
                                        .AddStarWarsTypes()
                                        .Create()
                                        .MakeExecutable();
            var handler = new DataStartMessageHandler(executor, interceptor);
            KeepConnectionAliveMessage message = KeepConnectionAliveMessage.Default;

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

            // assert
            Assert.False(result);
        }