예제 #1
0
        public async Task Unsubscribe_On_Complete_Message()
        {
            // arrange
            var test            = new SessionMessageQueue <PublishSchemaEvent>();
            var message         = new PublishSchemaEvent("abc", new Issue("def", IssueType.Error));
            var completeMessage = PublishSchemaEvent.Completed("abc");
            var received        = new List <PublishSchemaEvent>();

            await test.SendAsync(message);

            Task sendCompleteMessage = Task.Run(async() =>
            {
                await Task.Delay(250);
                await test.SendAsync(completeMessage);
            });

            // act
            await foreach (PublishSchemaEvent m in await test.SubscribeAsync(message.SessionId))
            {
                received.Add(m);

                if (received.Count == 1)
                {
                    await sendCompleteMessage;
                }
            }

            // assert
            Assert.Collection(received,
                              t => Assert.Equal(message, t),
                              t => Assert.Equal(completeMessage, t));
        }
예제 #2
0
        public async Task Send_And_Receive_Message()
        {
            // arrange
            var test    = new SessionMessageQueue <PublishSchemaEvent>();
            var message = new PublishSchemaEvent("abc", new Issue("def", IssueType.Error));

            // act
            await test.SendAsync(message);

            // assert
            await foreach (PublishSchemaEvent m in await test.SubscribeAsync(message.SessionId))
            {
                Assert.Equal(message, m);
                break;
            }
        }
예제 #3
0
        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 = "abc";

            await PublishSchemaEventSender.SendAsync(
                new PublishSchemaEvent(sessionId, new Issue("foo", IssueType.Information)));

            await PublishSchemaEventSender.SendAsync(
                PublishSchemaEvent.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();
        }