Ejemplo n.º 1
0
        public async Task ReceiveAsync_CommandEnvelope_ClientShouldReceive()
        {
            // Arrange
            var presence = Dummy.CreatePresence();
            var command  = Dummy.CreateCommand(presence);
            var target   = await GetTargetAndEstablish();

            await ServerTransport.SendAsync(command, CancellationToken);

            // Act
            var receivedEnvelope = await target.ReceiveAsync(CancellationToken);


            // Assert
            var actual = receivedEnvelope.ShouldBeOfType <Command>();

            actual.Id.ShouldBe(command.Id);
            actual.From.ShouldBe(command.From);
            actual.To.ShouldBe(command.To);
            var actualResource = actual.Resource.ShouldBeOfType <Presence>();

            actualResource.Status.ShouldBe(presence.Status);
            actualResource.Message.ShouldBe(presence.Message);
            actualResource.RoutingRule.ShouldBe(presence.RoutingRule);
            actualResource.Priority.ShouldBe(presence.Priority);
        }
Ejemplo n.º 2
0
        public async Task <RedisTransport> GetTargetAndEstablish()
        {
            var transport = await GetTargetAndOpenAsync();

            await transport.SendAsync(new Session { State = SessionState.New }, CancellationToken);

            ServerTransport = await Listener.AcceptTransportAsync(CancellationToken);

            await ServerTransport.ReceiveAsync(CancellationToken);

            EstablishedSession = Dummy.CreateSession(SessionState.Established);
            await ServerTransport.SendAsync(EstablishedSession, CancellationToken);

            await transport.ReceiveAsync(CancellationToken);

            return(transport);
        }
Ejemplo n.º 3
0
        public async Task ReceiveAsync_NotificationEnvelope_ClientShouldReceive()
        {
            // Arrange
            var notification = Dummy.CreateNotification(Event.Received);
            var target       = await GetTargetAndEstablish();

            await ServerTransport.SendAsync(notification, CancellationToken);

            // Act
            var receivedEnvelope = await target.ReceiveAsync(CancellationToken);

            // Assert
            var actual = receivedEnvelope.ShouldBeOfType <Notification>();

            actual.Id.ShouldBe(notification.Id);
            actual.From.ShouldBe(notification.From);
            actual.To.ShouldBe(notification.To);
            actual.Event.ShouldBe(notification.Event);
        }
Ejemplo n.º 4
0
        public async Task ReceiveAsync_MessageEnvelope_ClientShouldReceive()
        {
            // Arrange
            var content = Dummy.CreateTextContent();
            var message = Dummy.CreateMessage(content);
            var target  = await GetTargetAndEstablish();

            await ServerTransport.SendAsync(message, CancellationToken);

            // Act
            var receivedEnvelope = await target.ReceiveAsync(CancellationToken);

            // Assert
            var actual = receivedEnvelope.ShouldBeOfType <Message>();

            actual.Id.ShouldBe(message.Id);
            actual.From.ShouldBe(message.From);
            actual.To.ShouldBe(message.To);
            var actualContent = actual.Content.ShouldBeOfType <PlainText>();

            actualContent.Text.ShouldBe(content.Text);
        }