public async Task SendAsync_CommandEnvelope_ServerShouldReceive() { // Arrange var presence = Dummy.CreatePresence(); var command = Dummy.CreateCommand(presence); var target = await GetTargetAndEstablish(); // Act await target.SendAsync(command, CancellationToken); // Assert var receivedEnvelope = await ServerTransport.ReceiveAsync(CancellationToken); 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); }
public Task SendReceiveAsync() { var receiveTask = ServerTransport.ReceiveAsync(CancellationToken); var sendTask = ClientTransport.SendAsync(Message, CancellationToken); return(Task.WhenAll(receiveTask, sendTask)); }
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); }
public async Task SendAsync_NotificationEnvelope_ServerShouldReceive() { // Arrange var notification = Dummy.CreateNotification(Event.Received); var target = await GetTargetAndEstablish(); // Act await target.SendAsync(notification, CancellationToken); // Assert var receivedEnvelope = await ServerTransport.ReceiveAsync(CancellationToken); 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); }
public async Task SendAsync_FinishingSessionEnvelope_ServerShouldReceive() { // Arrange var target = await GetTargetAndEstablish(); var session = Dummy.CreateSession(SessionState.Finishing); session.Id = EstablishedSession.Id; // Act await target.SendAsync(session, CancellationToken); // Assert var receivedEnvelope = await ServerTransport.ReceiveAsync(CancellationToken); var actualSession = receivedEnvelope.ShouldBeOfType <Session>(); actualSession.State.ShouldBe(SessionState.Finishing); }
public async Task SendAsync_MessageEnvelope_ServerShouldReceive() { // Arrange var content = Dummy.CreateTextContent(); var message = Dummy.CreateMessage(content); var target = await GetTargetAndEstablish(); // Act await target.SendAsync(message, CancellationToken); // Assert var receivedEnvelope = await ServerTransport.ReceiveAsync(CancellationToken); 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); }