コード例 #1
0
        public async Task Test_PushEventNotifyAsync_WhenHaveConnection()
        {
            var userId         = Guid.NewGuid();
            var connectionId   = Guid.NewGuid().ToString("N");
            var conversationId = Guid.NewGuid();

            void configBus(IInMemoryReceiveEndpointConfigurator e)
            {
                e.Handler <SendEventNotify>(context =>
                {
                    var notify = context.Message;

                    Assert.IsNotNull(notify);
                    Assert.AreEqual(1, notify.Notifies.Count);
                    Assert.AreEqual(conversationId.ToString(), notify.Notifies[0].TargetId);
                    Assert.AreEqual(1, notify.Notifies[0].TargetCategory);
                    Assert.AreEqual("Test", notify.Notifies[0].Text);

                    return(Task.CompletedTask);
                });

                MapEndpointConverion(e);
            };

            var actor = new TheActor(CreateActorService(CreateBus(configBus)), new ActorId(userId));

            actor.IsInUnitTest = true;

            await actor.AddConnectionIdAsync(connectionId);

            await actor.PushEventNotifyAsync(new EventNotifyDto
            {
                Target         = NotifyTargetType.Conversation,
                TargetId       = conversationId.ToString(),
                Text           = "Test",
                TargetCategory = 1
            });

            await Task.Delay(500);
        }