diff --git a/Test/Realtime.Test/Message.cs b/Test/Realtime.Test/Message.cs index cdebaaf..39dc034 100644 --- a/Test/Realtime.Test/Message.cs +++ b/Test/Realtime.Test/Message.cs @@ -2,6 +2,7 @@ using System; using System.Collections.ObjectModel; using System.Threading.Tasks; +using System.Collections.Generic; using LeanCloud; using LeanCloud.Common; using LeanCloud.Storage; @@ -171,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}"); @@ -181,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; } @@ -230,5 +242,41 @@ namespace Realtime.Test { await tcs.Task; } + + [Test] + [Order(8)] + public async Task MentionList() { + TaskCompletionSource tcs = new TaskCompletionSource(); + m2.OnMessage = (conv, msg) => { + Assert.True(msg.Mentioned); + Assert.True(msg.MentionIdList.Contains(m2.Id)); + tcs.SetResult(null); + }; + + LCIMTextMessage textMessage = new LCIMTextMessage("hello") { + MentionIdList = new List { m2.Id } + }; + await conversation.Send(textMessage); + + await tcs.Task; + } + + [Test] + [Order(9)] + public async Task MentionAll() { + TaskCompletionSource tcs = new TaskCompletionSource(); + m2.OnMessage = (conv, msg) => { + Assert.True(msg.Mentioned); + Assert.True(msg.MentionAll); + tcs.SetResult(null); + }; + + LCIMTextMessage textMessage = new LCIMTextMessage("world") { + MentionAll = true + }; + await conversation.Send(textMessage); + + await tcs.Task; + } } } diff --git a/Test/Realtime.Test/Protobuf.cs b/Test/Realtime.Test/Protobuf.cs index e1eef21..fdb8d33 100644 --- a/Test/Realtime.Test/Protobuf.cs +++ b/Test/Realtime.Test/Protobuf.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using LeanCloud.Realtime.Protocol; +using LeanCloud.Realtime.Internal.Protocol; using Google.Protobuf; namespace Realtime.Test { diff --git a/Test/Storage.Test/ACLTest.cs b/Test/Storage.Test/ACLTest.cs index 9614cd1..967da0c 100644 --- a/Test/Storage.Test/ACLTest.cs +++ b/Test/Storage.Test/ACLTest.cs @@ -1,9 +1,9 @@ using NUnit.Framework; using System.Threading.Tasks; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class ACLTest { [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/CloudTest.cs b/Test/Storage.Test/CloudTest.cs index 71df58d..2084a74 100644 --- a/Test/Storage.Test/CloudTest.cs +++ b/Test/Storage.Test/CloudTest.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Threading.Tasks; using System.Linq; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class CloudTest { [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/ExceptionTest.cs b/Test/Storage.Test/ExceptionTest.cs index 2341cb5..83f70b3 100644 --- a/Test/Storage.Test/ExceptionTest.cs +++ b/Test/Storage.Test/ExceptionTest.cs @@ -1,8 +1,7 @@ using NUnit.Framework; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class ExceptionTest { [Test] public void LeanCloudException() { diff --git a/Test/Storage.Test/FileTest.cs b/Test/Storage.Test/FileTest.cs index 19852da..4912857 100644 --- a/Test/Storage.Test/FileTest.cs +++ b/Test/Storage.Test/FileTest.cs @@ -2,13 +2,13 @@ using System; using System.Text; using System.Threading.Tasks; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class FileTest { - static readonly string AvatarFilePath = "../../../assets/hello.png"; - static readonly string APKFilePath = "../../../assets/test.apk"; + static readonly string AvatarFilePath = "../../../../assets/hello.png"; + static readonly string APKFilePath = "../../../../assets/test.apk"; [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/GeoTest.cs b/Test/Storage.Test/GeoTest.cs index 64eacdf..c2e413f 100644 --- a/Test/Storage.Test/GeoTest.cs +++ b/Test/Storage.Test/GeoTest.cs @@ -1,7 +1,7 @@ using NUnit.Framework; using LeanCloud.Storage; -namespace LeanCloud.Test { +namespace Storage.Test { public class GeoTest { [Test] public void Calculate() { diff --git a/Test/Storage.Test/ObjectTest.cs b/Test/Storage.Test/ObjectTest.cs index 81bcf54..399f2af 100644 --- a/Test/Storage.Test/ObjectTest.cs +++ b/Test/Storage.Test/ObjectTest.cs @@ -2,10 +2,10 @@ using NUnit.Framework; using System; using System.Threading.Tasks; using System.Collections.Generic; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class ObjectTest { [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/OperationTest.cs b/Test/Storage.Test/OperationTest.cs index 5e70100..4a82013 100644 --- a/Test/Storage.Test/OperationTest.cs +++ b/Test/Storage.Test/OperationTest.cs @@ -1,10 +1,10 @@ using NUnit.Framework; using System.Collections.Generic; using System.Threading.Tasks; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class OperationTest { [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/QueryTest.cs b/Test/Storage.Test/QueryTest.cs index de6041e..8bd009a 100644 --- a/Test/Storage.Test/QueryTest.cs +++ b/Test/Storage.Test/QueryTest.cs @@ -1,10 +1,10 @@ using NUnit.Framework; using System.Collections.Generic; using System.Threading.Tasks; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class QueryTest { [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/RelationTest.cs b/Test/Storage.Test/RelationTest.cs index f66c1e2..5ba3813 100644 --- a/Test/Storage.Test/RelationTest.cs +++ b/Test/Storage.Test/RelationTest.cs @@ -1,11 +1,10 @@ using NUnit.Framework; using System.Threading.Tasks; using System.Collections.Generic; -using System.Linq; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class RelationTest { [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/RoleTest.cs b/Test/Storage.Test/RoleTest.cs index 49c0179..51460af 100644 --- a/Test/Storage.Test/RoleTest.cs +++ b/Test/Storage.Test/RoleTest.cs @@ -2,11 +2,10 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using System.Linq; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { [TestFixture] public class RoleTest { [SetUp] diff --git a/Test/Storage.Test/SubClassTest.cs b/Test/Storage.Test/SubClassTest.cs index a06595f..fb599af 100644 --- a/Test/Storage.Test/SubClassTest.cs +++ b/Test/Storage.Test/SubClassTest.cs @@ -1,10 +1,10 @@ using NUnit.Framework; using System.Threading.Tasks; using System.Collections.Generic; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { internal class Hello : LCObject { internal World World => this["objectValue"] as World; diff --git a/Test/Storage.Test/UserTest.cs b/Test/Storage.Test/UserTest.cs index 3af8c44..53a0cb5 100644 --- a/Test/Storage.Test/UserTest.cs +++ b/Test/Storage.Test/UserTest.cs @@ -2,10 +2,10 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using LeanCloud; using LeanCloud.Storage; -using LeanCloud.Common; -namespace LeanCloud.Test { +namespace Storage.Test { public class UserTest { [SetUp] public void SetUp() { diff --git a/Test/Storage.Test/Utils.cs b/Test/Storage.Test/Utils.cs index 91e0a9b..e7e6df2 100644 --- a/Test/Storage.Test/Utils.cs +++ b/Test/Storage.Test/Utils.cs @@ -1,9 +1,7 @@ -using System; +using NUnit.Framework; using LeanCloud; -using LeanCloud.Common; -using NUnit.Framework; -namespace LeanCloud.Test { +namespace Storage.Test { public static class Utils { internal static void Print(LCLogLevel level, string info) { switch (level) { diff --git a/Test/Storage.Test/assets/hello.png b/Test/assets/hello.png similarity index 100% rename from Test/Storage.Test/assets/hello.png rename to Test/assets/hello.png diff --git a/Test/Storage.Test/assets/test.apk b/Test/assets/test.apk similarity index 100% rename from Test/Storage.Test/assets/test.apk rename to Test/assets/test.apk