private async Task Notification_RedirectedViaChannel()
{
// Arrange
var channel = ActorOf(Props.Create(() => new TestActorBoundChannel(context =>
new[] { Tuple.Create(context.ActorOf<SubjectActor>(null), new TaggedType[] { typeof(ISubject) }, ActorBindingFlags.CloseThenStop) })));
var channelRef = channel.Cast<ActorBoundChannelRef>();
var actorId = 1;
// Act
var notifications = new List<NotificationMessage>();
var r1 = await channel.Ask<ResponseMessage>(new TestActorBoundChannel.Request
{
ActorId = actorId,
Message = new RequestMessage
{
RequestId = 1,
InvokePayload = new ISubject_PayloadTable.Subscribe_Invoke
{
observer = new SubjectObserver(new TestNotificationChannel { Messages = notifications }, 1)
}
}
});
Assert.Equal(1, r1.RequestId);
var r2 = await channel.Ask<ResponseMessage>(new TestActorBoundChannel.Request
{
ActorId = actorId,
Message = new RequestMessage
{
RequestId = 2,
InvokePayload = new ISubject_PayloadTable.MakeEvent_Invoke
{
eventName = "Test"
}
}
});
Assert.Equal(2, r2.RequestId);
// Assert
Assert.Equal(1, notifications.Count);
Assert.Equal(1, notifications[0].ObserverId);
Assert.Equal("Test", ((ISubjectObserver_PayloadTable.Event_Invoke)notifications[0].InvokePayload).eventName);
}