From 6994c79c515a1e0087243e5d720bb344a13379b6 Mon Sep 17 00:00:00 2001 From: oneRain Date: Tue, 28 Apr 2020 15:09:51 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=AE=8C=E5=96=84=E6=9C=AA=E8=AF=BB?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=95=B0=E9=87=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/Realtime.Test/Message.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Test/Realtime.Test/Message.cs b/Test/Realtime.Test/Message.cs index 3de142e..39dc034 100644 --- a/Test/Realtime.Test/Message.cs +++ b/Test/Realtime.Test/Message.cs @@ -172,9 +172,10 @@ namespace Realtime.Test { string clientId = Guid.NewGuid().ToString(); LCIMClient client = new LCIMClient(clientId); LCIMConversation conversation = await m1.CreateConversation(new string[] { clientId }); - await client.Open(); + LCIMTextMessage textMessage = new LCIMTextMessage("hello"); await conversation.Send(textMessage); + client.OnUnreadMessagesCountUpdated = (convs) => { foreach (LCIMConversation conv in convs) { WriteLine($"unread count: {conv.Unread}"); @@ -182,11 +183,21 @@ namespace Realtime.Test { Assert.True(conv.LastMessage is LCIMTextMessage); LCIMTextMessage textMsg = conv.LastMessage as LCIMTextMessage; Assert.AreEqual(textMsg.Text, "hello"); - tcs.SetResult(true); } }; await client.Open(); + client.OnMessage = (conv, msg) => { + WriteLine($"unread count: {conv.Unread}"); + Assert.AreEqual(conv.Unread, 2); + Assert.True(conv.LastMessage is LCIMTextMessage); + LCIMTextMessage textMsg = conv.LastMessage as LCIMTextMessage; + Assert.AreEqual(textMsg.Text, "world"); + tcs.SetResult(true); + }; + textMessage = new LCIMTextMessage("world"); + await conversation.Send(textMessage); + await tcs.Task; }