public async Task ExecutePublishDocumentServer_With_SchemaFile_Handler()
        {
            // arrange
            string sessionId = await SessionCreator.CreateSessionAsync();

            var handler = new PublishNewSchemaDocumentHandler(
                Storage, SchemaRepository, PublishSchemaEventSender);

            using var service = new PublishDocumentService(
                      PublishDocumentMessageReceiver, new
                      IPublishDocumentHandler[] { handler });

            var schema = new Schema("abc", "def");
            await SchemaRepository.AddSchemaAsync(schema);

            var environment = new Environment("abc", "def");
            await EnvironmentRepository.AddEnvironmentAsync(environment);

            var message = new PublishDocumentMessage(
                sessionId, environment.Id, schema.Id, "externalId", Array.Empty <Tag>());

            IFileContainer fileContainer = await Storage.CreateContainerAsync(sessionId);

            byte[] buffer = Encoding.UTF8.GetBytes(@"
                    type Query {
                        foo: String
                    }
                ");
            await fileContainer.CreateFileAsync("schema.graphql", buffer, 0, buffer.Length);

            await PublishDocumentMessageSender.SendAsync(message);

            // act
            await service.StartAsync(default);
        public async Task OnPublishSchema()
        {
            // arrange
            var serializer = new IdSerializer();

            var schema = new Schema("abc", "def");
            await SchemaRepository.AddSchemaAsync(schema);

            var environment = new Environment("abc", "def");
            await EnvironmentRepository.AddEnvironmentAsync(environment);

            string sessionId = await SessionCreator.CreateSessionAsync();

            await PublishSchemaEventSender.SendAsync(
                new PublishDocumentEvent(
                    sessionId,
                    new Issue("foo", "file.graphql", new Location(0, 0, 1, 1),
                              IssueType.Information)));

            await PublishSchemaEventSender.SendAsync(
                PublishDocumentEvent.Completed(sessionId));

            // act
            var responseStream = (IResponseStream)await Executor.ExecuteAsync(
                QueryRequestBuilder.New()
                .SetQuery(
                    @"subscription(
                            $sessionId: String!) {
                            onPublishSchema(sessionId: $sessionId) {
                                sessionId
                                isCompleted
                            }
                        }")
                .SetVariableValue("sessionId", sessionId)
                .Create());

            // assert
            var results = new List <IReadOnlyQueryResult>();

            await foreach (IReadOnlyQueryResult result in responseStream)
            {
                results.Add(result);
            }

            results.MatchSnapshot(matchOptions =>
                                  matchOptions.Assert(fieldOption =>
                                                      Assert.Collection(
                                                          fieldOption.Fields <string>("[*].Data.onPublishSchema.sessionId"),
                                                          t => Assert.Equal(sessionId, t),
                                                          t => Assert.Equal(sessionId, t))));
        }
        public async Task HandleMessage()
        {
            // arrange
            string sessionId = await SessionCreator.CreateSessionAsync();

            var handler = new PublishNewSchemaDocumentHandler(
                Storage, SchemaRepository, PublishSchemaEventSender);

            var schema = new Schema("abc", "def");
            await SchemaRepository.AddSchemaAsync(schema);

            var environment = new Environment("abc", "def");
            await EnvironmentRepository.AddEnvironmentAsync(environment);

            var message = new PublishDocumentMessage(
                sessionId,
                environment.Id,
                schema.Id,
                "externalId",
                Array.Empty <DocumentInfo>(),
                Array.Empty <Tag>());

            IFileContainer fileContainer = await Storage.CreateContainerAsync(sessionId);

            byte[] buffer = Encoding.UTF8.GetBytes(@"
                    type Query {
                        foo: String
                    }
                ");
            await fileContainer.CreateFileAsync("schema.graphql", buffer, 0, buffer.Length);

            // act
            await handler.HandleAsync(message, default);

            // assert
            var list = new List <PublishDocumentEvent>();

            using var cts = new CancellationTokenSource(5000);
            IAsyncEnumerable <PublishDocumentEvent> eventStream =
                await PublishSchemaEventReceiver.SubscribeAsync(sessionId, cts.Token);

            await foreach (PublishDocumentEvent eventMessage in
                           eventStream.WithCancellation(cts.Token))
            {
                list.Add(eventMessage);
            }
            list.MatchSnapshot(matchOption =>
                               matchOption.Assert(fieldOption =>
                                                  Assert.Equal(sessionId, fieldOption.Field <string>("[0].SessionId"))));
        }