test: 完善未读消息数量测试

oneRain 2020-04-28 15:09:51 +08:00
parent cce620724a
commit 6994c79c51
1 changed files with 13 additions and 2 deletions

View File

@ -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;
}