test: 消息自定义属性

oneRain 2020-04-27 14:47:04 +08:00
parent 9dd7a19e03
commit 5379ee1285
1 changed files with 21 additions and 0 deletions

View File

@ -171,5 +171,26 @@ namespace Realtime.Test {
await tcs.Task; await tcs.Task;
} }
[Test]
[Order(6)]
public async Task Attributes() {
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
m2.OnMessage = (conv, msg) => {
Assert.True(msg is LCIMTypedMessage);
LCIMTypedMessage typedMsg = msg as LCIMTypedMessage;
Assert.AreEqual(typedMsg["k1"], 123);
Assert.True((bool)typedMsg["k2"]);
Assert.AreEqual(typedMsg["k3"], "code");
tcs.SetResult(null);
};
LCIMTextMessage textMsg = new LCIMTextMessage("hi");
textMsg["k1"] = 123;
textMsg["k2"] = true;
textMsg["k3"] = "code";
await conversation.Send(textMsg);
await tcs.Task;
}
} }
} }