chore: storage unit test

oneRain 2021-04-29 15:58:22 +08:00
parent d3a1f055af
commit 0908e9e3d9
19 changed files with 389 additions and 456 deletions

View File

@ -1,46 +1,41 @@
using NUnit.Framework; using NUnit.Framework;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System;
using LeanCloud; using LeanCloud;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class ACLTest { public class ACLTest : BaseTest {
[SetUp] private Account account;
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
[Order(0)]
public async Task PrivateReadAndWrite() { public async Task PrivateReadAndWrite() {
LCObject account = new LCObject("Account"); Account account = new Account();
LCACL acl = new LCACL(); account.ACL = new LCACL {
acl.PublicReadAccess = false; PublicReadAccess = false,
acl.PublicWriteAccess = false; PublicWriteAccess = false
account.ACL = acl; };
account.Balance = 1024;
account["balance"] = 1024; account["balance"] = 1024;
await account.Save(); await account.Save();
Assert.IsFalse(acl.PublicReadAccess); Assert.IsFalse(account.ACL.PublicReadAccess);
Assert.IsFalse(acl.PublicWriteAccess); Assert.IsFalse(account.ACL.PublicWriteAccess);
} }
[Test] [Test]
[Order(1)]
public async Task UserReadAndWrite() { public async Task UserReadAndWrite() {
await LCUser.Login("hello", "world"); await LCUser.Login(TestPhone, TestPhone);
LCObject account = new LCObject("Account"); account = new Account();
LCUser currentUser = await LCUser.GetCurrent(); LCUser currentUser = await LCUser.GetCurrent();
LCACL acl = LCACL.CreateWithOwner(currentUser); account.ACL = LCACL.CreateWithOwner(currentUser);
account.ACL = acl; account.Balance = 512;
account["balance"] = 512;
await account.Save(); await account.Save();
Assert.IsTrue(acl.GetUserReadAccess(currentUser)); Assert.IsTrue(account.ACL.GetUserReadAccess(currentUser));
Assert.IsTrue(acl.GetUserWriteAccess(currentUser)); Assert.IsTrue(account.ACL.GetUserWriteAccess(currentUser));
LCQuery<LCObject> query = new LCQuery<LCObject>("Account"); LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject result = await query.Get(account.ObjectId); LCObject result = await query.Get(account.ObjectId);
@ -57,29 +52,39 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(2)]
public async Task RoleReadAndWrite() { public async Task RoleReadAndWrite() {
LCQuery<LCRole> query = LCRole.GetQuery(); LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);
LCRole owner = await query.Get("5e1440cbfc36ed006add1b8d"); string name = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
LCObject account = new LCObject("Account"); LCACL roleACL = new LCACL();
roleACL.SetUserReadAccess(currentUser, true);
roleACL.SetUserWriteAccess(currentUser, true);
LCRole role = LCRole.Create(name, roleACL);
role.AddRelation("users", currentUser);
await role.Save();
account = new Account();
LCACL acl = new LCACL(); LCACL acl = new LCACL();
acl.SetRoleReadAccess(owner, true); acl.SetRoleReadAccess(role, true);
acl.SetRoleWriteAccess(owner, true); acl.SetRoleWriteAccess(role, true);
account.ACL = acl; account.ACL = acl;
await account.Save(); await account.Save();
Assert.IsTrue(acl.GetRoleReadAccess(owner)); Assert.IsTrue(acl.GetRoleReadAccess(role));
Assert.IsTrue(acl.GetRoleWriteAccess(owner)); Assert.IsTrue(acl.GetRoleWriteAccess(role));
} }
[Test] [Test]
[Order(3)]
public async Task Query() { public async Task Query() {
await LCUser.Login("game", "play"); await LCUser.Login(TestPhone, TestPhone);
LCQuery<LCObject> query = new LCQuery<LCObject>("Account"); LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject account = await query.Get("5e144525dd3c13006a8f8de2"); Account queryAccount = (await query.Get(account.ObjectId)) as Account;
TestContext.WriteLine(account.ObjectId); TestContext.WriteLine(queryAccount.ObjectId);
Assert.NotNull(account.ObjectId); Assert.NotNull(queryAccount.ObjectId);
} }
[Test] [Test]
[Order(4)]
public async Task Serialization() { public async Task Serialization() {
await LCUser.Login("hello", "world"); await LCUser.Login("hello", "world");
LCQuery<LCObject> query = new LCQuery<LCObject>("Account") { LCQuery<LCObject> query = new LCQuery<LCObject>("Account") {

View File

@ -0,0 +1,86 @@
using NUnit.Framework;
using LeanCloud;
using LeanCloud.Storage;
namespace Storage.Test {
internal class Hello : LCObject {
internal World World {
get => this["objectValue"] as World;
set {
this["objectValue"] = value;
}
}
internal Hello() : base("Hello") { }
}
internal class World : LCObject {
internal string Content {
get => this["content"] as string;
set {
this["content"] = value;
}
}
internal World() : base("World") { }
}
internal class Account : LCObject {
internal int Balance {
get => (int)this["balance"];
set {
this["balance"] = value;
}
}
internal LCUser User {
get => this["user"] as LCUser;
set {
this["user"] = value;
}
}
internal Account() : base("Account") { }
}
public class BaseTest {
internal const string AppId = "ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz";
internal const string AppKey = "NUKmuRbdAhg1vrb2wexYo1jo";
internal const string MasterKey = "pyvbNSh5jXsuFQ3C8EgnIdhw";
internal const string AppServer = "https://ikggdre2.lc-cn-n1-shared.com";
internal const string TestPhone = "18888888888";
internal const string TestSMSCode = "235750";
[SetUp]
public virtual void SetUp() {
LCLogger.LogDelegate += Print;
LCApplication.Initialize(AppId, AppKey, AppServer);
LCObject.RegisterSubclass("Account", () => new Account());
LCObject.RegisterSubclass<Hello>("Hello", () => new Hello());
LCObject.RegisterSubclass<World>("World", () => new World());
}
[TearDown]
public virtual void TearDown() {
LCLogger.LogDelegate -= Print;
}
internal static void Print(LCLogLevel level, string info) {
switch (level) {
case LCLogLevel.Debug:
TestContext.Out.WriteLine($"[DEBUG] {info}");
break;
case LCLogLevel.Warn:
TestContext.Out.WriteLine($"[WARNING] {info}");
break;
case LCLogLevel.Error:
TestContext.Out.WriteLine($"[ERROR] {info}");
break;
default:
TestContext.Out.WriteLine(info);
break;
}
}
}
}

View File

@ -1,22 +1,11 @@
using NUnit.Framework; using NUnit.Framework;
using System.Threading.Tasks; using System.Threading.Tasks;
using LeanCloud;
using LeanCloud.Storage; using LeanCloud.Storage;
using static NUnit.Framework.TestContext; using static NUnit.Framework.TestContext;
namespace Storage.Test { namespace Storage.Test {
public class CaptchaTest { public class CaptchaTest : BaseTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
//[Test] //[Test]
public async Task Request() { public async Task Request() {
LCCapture captcha = await LCCaptchaClient.RequestCaptcha(); LCCapture captcha = await LCCaptchaClient.RequestCaptcha();

View File

@ -2,83 +2,60 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Linq; using System.Linq;
using LeanCloud;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class CloudTest { public class CloudTest : BaseTest {
[SetUp] [Test]
public void SetUp() { public async Task Ping() {
LCLogger.LogDelegate += Utils.Print; Dictionary<string, object> response = await LCCloud.Run("ping");
//LCApplication.Initialize("ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz", "NUKmuRbdAhg1vrb2wexYo1jo", "https://ikggdre2.lc-cn-n1-shared.com"); TestContext.WriteLine(response["result"]);
LCApplication.Initialize("8ijVI3gBAnPGynW0rVfh5gHP-gzGzoHsz", "265r8JSHhNYpV0qIJBvUWrQY", "https://8ijvi3gb.lc-cn-n1-shared.com"); Assert.AreEqual(response["result"], "pong");
}
[TearDown]
public void TearDown() {
LCLogger.LogDelegate -= Utils.Print;
} }
[Test] [Test]
public async Task Call() { public async Task Hello() {
Dictionary<string, object> response = await LCCloud.Run("hello", parameters: new Dictionary<string, object> { string result = await LCCloud.Run<string>("hello", new Dictionary<string, object> {
{ "name", "world" } { "name", "world" }
}); });
TestContext.WriteLine(response["result"]); TestContext.WriteLine(result);
Assert.AreEqual(response["result"], "Hello, world!"); Assert.AreEqual(result, "hello, world");
} }
[Test] [Test]
public async Task RunAverageScore() { public async Task GetObject() {
float score = await LCCloud.Run<float>("averageStars", new Dictionary<string, object> { LCObject hello = new LCObject("Hello");
{ "movie", "夏洛特烦恼" } await hello.Save();
object reponse = await LCCloud.RPC("getObject", new Dictionary<string, object> {
{ "className", "Hello" },
{ "id", hello.ObjectId }
}); });
TestContext.WriteLine($"score: {score}"); LCObject obj = reponse as LCObject;
Assert.True(score.Equals(3.8f)); Assert.AreEqual(obj.ObjectId, hello.ObjectId);
} }
[Test] [Test]
public async Task CallWithoutParams() { public async Task GetObjects() {
await LCCloud.Run("hello"); object response = await LCCloud.RPC("getObjects");
} List<object> list = response as List<object>;
IEnumerable<LCObject> objects = list.Cast<LCObject>();
[Test] TestContext.WriteLine(objects.Count());
public async Task RPC() { Assert.Greater(objects.Count(), 0);
List<object> result = await LCCloud.RPC("getTycoonList") as List<object>; foreach (LCObject obj in objects) {
IEnumerable<LCObject> tycoonList = result.Cast<LCObject>(); int balance = (int)obj["balance"];
foreach (LCObject item in tycoonList) { Assert.Greater(balance, 100);
TestContext.WriteLine(item.ObjectId);
Assert.NotNull(item.ObjectId);
} }
} }
[Test] [Test]
public async Task RPCObject() { public async Task GetObjectMap() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Todo"); object response = await LCCloud.RPC("getObjectMap");
LCObject todo = await query.Get("6052cd87b725a143ea83dbf8"); Dictionary<string, object> dict = response as Dictionary<string, object>;
object result = await LCCloud.RPC("getTodo", todo); TestContext.WriteLine(dict.Count);
LCObject obj = result as LCObject; Assert.Greater(dict.Count, 0);
TestContext.WriteLine(obj.ToString()); foreach (KeyValuePair<string, object> kv in dict) {
} LCObject obj = kv.Value as LCObject;
Assert.AreEqual(kv.Key, obj.ObjectId);
[Test]
public async Task RPCObjects() {
Dictionary<string, object> parameters = new Dictionary<string, object> {
{ "limit", 20 }
};
List<object> result = await LCCloud.RPC("getTodos", parameters) as List<object>;
IEnumerable<LCObject> todos = result.Cast<LCObject>();
foreach (LCObject todo in todos) {
TestContext.WriteLine(todo.ObjectId);
}
}
[Test]
public async Task RPCObjectMap() {
Dictionary<string, object> result = await LCCloud.RPC("getTodoMap") as Dictionary<string, object>;
foreach (KeyValuePair<string, object> kv in result) {
LCObject todo = kv.Value as LCObject;
TestContext.WriteLine(todo.ObjectId);
} }
} }
} }

View File

@ -2,7 +2,7 @@
using LeanCloud; using LeanCloud;
namespace Storage.Test { namespace Storage.Test {
public class ExceptionTest { public class ExceptionTest : BaseTest {
[Test] [Test]
public void LeanCloudException() { public void LeanCloudException() {
try { try {

View File

@ -6,39 +6,33 @@ using LeanCloud;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class FileTest { public class FileTest : BaseTest {
static readonly string AvatarFilePath = "../../../../../assets/hello.png"; static readonly string AvatarFilePath = "../../../../../assets/hello.png";
static readonly string APKFilePath = "../../../../../assets/test.apk"; static readonly string APKFilePath = "../../../../../assets/test.apk";
[SetUp] private LCFile avatar;
public void SetUp() {
Utils.SetUp();
}
[TearDown] [Test]
public void TearDown() { [Order(0)]
Utils.TearDown(); public async Task SaveFromPath() {
avatar = new LCFile("avatar", AvatarFilePath);
await avatar.Save((count, total) => {
TestContext.WriteLine($"progress: {count}/{total}");
});
TestContext.WriteLine(avatar.ObjectId);
Assert.NotNull(avatar.ObjectId);
} }
[Test] [Test]
[Order(1)]
public async Task QueryFile() { public async Task QueryFile() {
LCQuery<LCFile> query = LCFile.GetQuery(); LCQuery<LCFile> query = LCFile.GetQuery();
LCFile file = await query.Get("5e0dbfa0562071008e21c142"); LCFile file = await query.Get(avatar.ObjectId);
Assert.NotNull(file.Url); Assert.NotNull(file.Url);
TestContext.WriteLine(file.Url); TestContext.WriteLine(file.Url);
TestContext.WriteLine(file.GetThumbnailUrl(32, 32)); TestContext.WriteLine(file.GetThumbnailUrl(32, 32));
} }
[Test]
public async Task SaveFromPath() {
LCFile file = new LCFile("avatar", AvatarFilePath);
await file.Save((count, total) => {
TestContext.WriteLine($"progress: {count}/{total}");
});
TestContext.WriteLine(file.ObjectId);
Assert.NotNull(file.ObjectId);
}
[Test] [Test]
public async Task SaveFromMemory() { public async Task SaveFromMemory() {
string text = "hello, world"; string text = "hello, world";
@ -69,17 +63,6 @@ namespace Storage.Test {
Assert.NotNull(file.ObjectId); Assert.NotNull(file.ObjectId);
} }
[Test]
public async Task AWS() {
LCApplication.Initialize("UlCpyvLm8aMzQsW6KnP6W3Wt-MdYXbMMI", "PyCTYoNoxCVoKKg394PBeS4r");
LCFile file = new LCFile("avatar", AvatarFilePath);
await file.Save((count, total) => {
TestContext.WriteLine($"progress: {count}/{total}");
});
TestContext.WriteLine(file.ObjectId);
Assert.NotNull(file.ObjectId);
}
[Test] [Test]
public async Task FileACL() { public async Task FileACL() {
LCUser user = await LCUser.LoginAnonymously(); LCUser user = await LCUser.LoginAnonymously();
@ -101,5 +84,16 @@ namespace Storage.Test {
Assert.AreEqual(e.Code, 403); Assert.AreEqual(e.Code, 403);
} }
} }
//[Test]
//public async Task AWS() {
// LCApplication.Initialize("UlCpyvLm8aMzQsW6KnP6W3Wt-MdYXbMMI", "PyCTYoNoxCVoKKg394PBeS4r");
// LCFile file = new LCFile("avatar", AvatarFilePath);
// await file.Save((count, total) => {
// TestContext.WriteLine($"progress: {count}/{total}");
// });
// TestContext.WriteLine(file.ObjectId);
// Assert.NotNull(file.ObjectId);
//}
} }
} }

View File

@ -8,7 +8,7 @@ using LeanCloud;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class FriendTest { public class FriendTest : BaseTest {
async Task<LCUser> SignUp() { async Task<LCUser> SignUp() {
LCUser user = new LCUser { LCUser user = new LCUser {
Username = Guid.NewGuid().ToString(), Username = Guid.NewGuid().ToString(),
@ -36,16 +36,6 @@ namespace Storage.Test {
private LCUser user1; private LCUser user1;
private LCUser user2; private LCUser user2;
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
[Order(0)] [Order(0)]
public async Task Init() { public async Task Init() {

View File

@ -2,7 +2,7 @@
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class GeoTest { public class GeoTest : BaseTest {
[Test] [Test]
public void Calculate() { public void Calculate() {
LCGeoPoint p1 = new LCGeoPoint(20.0059, 110.3665); LCGeoPoint p1 = new LCGeoPoint(20.0059, 110.3665);

View File

@ -9,21 +9,21 @@ using LeanCloud.Storage;
using static NUnit.Framework.TestContext; using static NUnit.Framework.TestContext;
namespace Storage.Test { namespace Storage.Test {
public class LeaderboardTest { public class LeaderboardTest : BaseTest {
private string leaderboardName; private string leaderboardName;
[SetUp] [SetUp]
public void SetUp() { public override void SetUp() {
LCLogger.LogDelegate += Utils.Print; base.SetUp();
LCApplication.Initialize(Utils.AppId, Utils.AppKey, Utils.AppServer, Utils.MasterKey); LCApplication.Initialize(AppId, AppKey, AppServer, MasterKey);
LCApplication.UseMasterKey = true; LCApplication.UseMasterKey = true;
leaderboardName = $"Leaderboard_{DateTimeOffset.Now.DayOfYear}"; leaderboardName = $"Leaderboard_{DateTimeOffset.Now.DayOfYear}";
} }
[TearDown] [TearDown]
public void TearDown() { public override void TearDown() {
base.TearDown();
LCApplication.UseMasterKey = false; LCApplication.UseMasterKey = false;
Utils.TearDown();
} }
[Test] [Test]

View File

@ -2,26 +2,17 @@ using NUnit.Framework;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using LeanCloud; using LeanCloud;
using LeanCloud.Storage; using LeanCloud.Storage;
using static NUnit.Framework.TestContext; using static NUnit.Framework.TestContext;
namespace Storage.Test { namespace Storage.Test {
public class ObjectTest { public class ObjectTest : BaseTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
public async Task CreateObject() { public async Task CreateObject() {
LCObject @object = new LCObject("Hello"); Hello @object = new Hello();
@object["intValue"] = 123; @object["intValue"] = 123;
@object["boolValue"] = true; @object["boolValue"] = true;
@object["stringValue"] = "hello, world"; @object["stringValue"] = "hello, world";
@ -38,19 +29,19 @@ namespace Storage.Test {
@object["pointerList"] = new List<object> { new LCObject("World"), nestedObj }; @object["pointerList"] = new List<object> { new LCObject("World"), nestedObj };
await @object.Save(); await @object.Save();
TestContext.WriteLine(@object.ClassName); WriteLine(@object.ClassName);
TestContext.WriteLine(@object.ObjectId); WriteLine(@object.ObjectId);
TestContext.WriteLine(@object.CreatedAt); WriteLine(@object.CreatedAt);
TestContext.WriteLine(@object.UpdatedAt); WriteLine(@object.UpdatedAt);
TestContext.WriteLine(@object["intValue"]); WriteLine(@object["intValue"]);
TestContext.WriteLine(@object["boolValue"]); WriteLine(@object["boolValue"]);
TestContext.WriteLine(@object["stringValue"]); WriteLine(@object["stringValue"]);
TestContext.WriteLine(@object["objectValue"]); WriteLine(@object["objectValue"]);
TestContext.WriteLine(@object["time"]); WriteLine(@object["time"]);
Assert.AreEqual(nestedObj, @object["objectValue"]); Assert.AreEqual(nestedObj, @object["objectValue"]);
TestContext.WriteLine(nestedObj.ClassName); WriteLine(nestedObj.ClassName);
TestContext.WriteLine(nestedObj.ObjectId); WriteLine(nestedObj.ObjectId);
Assert.NotNull(@object.ObjectId); Assert.NotNull(@object.ObjectId);
Assert.NotNull(@object.ClassName); Assert.NotNull(@object.ClassName);
@ -77,8 +68,9 @@ namespace Storage.Test {
public async Task SaveAll() { public async Task SaveAll() {
List<LCObject> list = new List<LCObject>(); List<LCObject> list = new List<LCObject>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
LCObject world = new LCObject("World"); World world = new World {
world["content"] = $"word_{i}"; Content = $"word_{i}"
};
list.Add(world); list.Add(world);
} }
await LCObject.SaveAll(list); await LCObject.SaveAll(list);
@ -89,18 +81,18 @@ namespace Storage.Test {
[Test] [Test]
public async Task Delete() { public async Task Delete() {
LCObject world = new LCObject("World"); World world = new World();
await world.Save(); await world.Save();
await world.Delete(); await world.Delete();
} }
[Test] [Test]
public async Task DeleteAll() { public async Task DeleteAll() {
List<LCObject> list = new List<LCObject> { List<World> list = new List<World> {
new LCObject("World"), new World(),
new LCObject("World"), new World(),
new LCObject("World"), new World(),
new LCObject("World") new World(),
}; };
await LCObject.SaveAll(list); await LCObject.SaveAll(list);
await LCObject.DeleteAll(list); await LCObject.DeleteAll(list);
@ -108,47 +100,53 @@ namespace Storage.Test {
[Test] [Test]
public async Task Fetch() { public async Task Fetch() {
LCObject hello = LCObject.CreateWithoutData("Hello", "5e14392743c257006fb769d5"); Hello hello = new Hello {
await hello.Fetch(includes: new List<string> { "objectValue" }); World = new World {
LCObject world = hello["objectValue"] as LCObject; Content = "7788"
TestContext.WriteLine(world["content"]); }
Assert.AreEqual(world["content"], "7788"); };
await hello.Save();
hello = LCObject.CreateWithoutData("Hello", hello.ObjectId) as Hello;
await hello.Fetch(includes: new string[] { "objectValue" });
World world = hello.World;
WriteLine(world.Content);
Assert.AreEqual(world.Content, "7788");
} }
[Test] [Test]
public async Task SaveWithOption() { public async Task SaveWithOption() {
LCObject account = new LCObject("Account"); Account account = new Account {
account["balance"] = 10; Balance = 10
};
await account.Save(); await account.Save();
account["balance"] = 1000;
LCQuery<LCObject> q = new LCQuery<LCObject>("Account"); LCQuery<LCObject> q = new LCQuery<LCObject>("Account");
q.WhereGreaterThan("balance", 100); q.WhereGreaterThan("balance", 100);
try { try {
await account.Save(fetchWhenSave: true, query: q); await account.Save(fetchWhenSave: true, query: q);
} catch(LCException e) { } catch(LCException e) {
TestContext.WriteLine($"{e.Code} : {e.Message}"); WriteLine($"{e.Code} : {e.Message}");
Assert.AreEqual(e.Code, 305); Assert.AreEqual(e.Code, 305);
} }
} }
[Test] [Test]
public async Task Unset() { public async Task Unset() {
LCObject hello = new LCObject("Hello"); Hello hello = new Hello {
hello["content"] = "hello, world"; World = new World()
};
await hello.Save(); await hello.Save();
TestContext.WriteLine(hello["content"]); Assert.NotNull(hello.World);
Assert.AreEqual(hello["content"], "hello, world");
hello.Unset("content"); hello.Unset("objectValue");
await hello.Save(); await hello.Save();
TestContext.WriteLine(hello["content"]); Assert.IsNull(hello.World);
Assert.IsNull(hello["content"]);
} }
[Test] [Test]
public async Task OperateNullProperty() { public async Task OperateNullProperty() {
LCObject obj = new LCObject("Hello"); Hello obj = new Hello();
obj.Increment("intValue", 123); obj.Increment("intValue", 123);
obj.Increment("intValue", 321); obj.Increment("intValue", 321);
obj.Add("intList", 1); obj.Add("intList", 1);
@ -168,21 +166,19 @@ namespace Storage.Test {
[Test] [Test]
public async Task FetchAll() { public async Task FetchAll() {
List<LCObject> list = new List<LCObject> { LCQuery<LCObject> query = new LCQuery<LCObject>("Hello");
LCObject.CreateWithoutData("Hello", "5e8fe86938ed12000870ae82"), IEnumerable<string> ids = (await query.Find()).Select(obj => obj.ObjectId);
LCObject.CreateWithoutData("Hello", "5e8fe867158a7a0006be0feb"), IEnumerable<LCObject> list = ids.Select(id => LCObject.CreateWithoutData("Hello", id));
LCObject.CreateWithoutData("Hello", "5e8fe84e5c385800081a1d64"),
};
await LCObject.FetchAll(list); await LCObject.FetchAll(list);
Assert.Greater(list.Count, 0); Assert.Greater(list.Count(), 0);
foreach (LCObject obj in list) { foreach (LCObject obj in list) {
Assert.NotNull(obj["intList"]); Assert.NotNull(obj.CreatedAt);
} }
} }
[Test] [Test]
public async Task Serialization() { public async Task Serialization() {
LCObject obj = new LCObject("Hello"); Hello obj = new Hello();
obj["intValue"] = 123; obj["intValue"] = 123;
obj["boolValue"] = true; obj["boolValue"] = true;
obj["stringValue"] = "hello, world"; obj["stringValue"] = "hello, world";

View File

@ -4,39 +4,31 @@ using System.Threading.Tasks;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class OperationTest { public class OperationTest : BaseTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
public async Task Increment() { public async Task Increment() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Account"); Account account = new Account {
LCObject account = await query.Get("5e154a5143c257006fbff63f"); Balance = 10
TestContext.WriteLine(account["balance"]); };
int balance = (int)account["balance"]; await account.Save();
TestContext.WriteLine(account.Balance);
account.Increment("balance", 100); account.Increment("balance", 100);
await account.Save(); await account.Save();
TestContext.WriteLine(account["balance"]); TestContext.WriteLine(account.Balance);
Assert.AreEqual((int)account["balance"], balance + 100); Assert.AreEqual(account.Balance, 110);
} }
[Test] [Test]
public async Task Decrement() { public async Task Decrement() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Account"); Account account = new Account {
LCObject account = await query.Get("5e154a5143c257006fbff63f"); Balance = 100
TestContext.WriteLine(account["balance"]); };
int balance = (int)account["balance"]; await account.Save();
TestContext.WriteLine(account.Balance);
account.Increment("balance", -10); account.Increment("balance", -10);
await account.Save(); await account.Save();
TestContext.WriteLine(account["balance"]); TestContext.WriteLine(account.Balance);
Assert.AreEqual((int)account["balance"], balance - 10); Assert.AreEqual(account.Balance, 90);
} }
[Test] [Test]

View File

@ -5,17 +5,7 @@ using System.Threading.Tasks;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class QueryTest { public class QueryTest : BaseTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
public async Task BaseQuery() { public async Task BaseQuery() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Hello"); LCQuery<LCObject> query = new LCQuery<LCObject>("Hello");
@ -80,19 +70,30 @@ namespace Storage.Test {
[Test] [Test]
public async Task Include() { public async Task Include() {
Hello hello = new Hello {
World = new World {
Content = "7788"
}
};
await hello.Save();
LCQuery<LCObject> query = new LCQuery<LCObject>("Hello"); LCQuery<LCObject> query = new LCQuery<LCObject>("Hello");
query.Include("objectValue"); query.Include("objectValue");
LCObject hello = await query.Get("5e0d55aedd3c13006a53cd87"); Hello queryHello = (await query.Get(hello.ObjectId)) as Hello;
LCObject world = hello["objectValue"] as LCObject; World world = queryHello.World;
TestContext.WriteLine(world["content"]); TestContext.WriteLine(world.Content);
Assert.AreEqual(world["content"], "7788"); Assert.AreEqual(world.Content, "7788");
} }
[Test] [Test]
public async Task Get() { public async Task Get() {
Account account = new Account {
Balance = 1024
};
await account.Save();
LCQuery<LCObject> query = new LCQuery<LCObject>("Account"); LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
LCObject account = await query.Get("5e0d9f7fd4b56c008e5d048a"); Account newAccount = (await query.Get(account.ObjectId)) as Account;
Assert.AreEqual(account["balance"], 400); Assert.AreEqual(newAccount.Balance, 1024);
} }
[Test] [Test]
@ -143,13 +144,19 @@ namespace Storage.Test {
[Test] [Test]
public async Task WhereObjectEquals() { public async Task WhereObjectEquals() {
World world = new World();
Hello hello = new Hello {
World = world
};
await hello.Save();
LCQuery<LCObject> worldQuery = new LCQuery<LCObject>("World"); LCQuery<LCObject> worldQuery = new LCQuery<LCObject>("World");
LCObject world = await worldQuery.Get("5e0d55ae21460d006a1ec931"); LCObject queryWorld = await worldQuery.Get(world.ObjectId);
LCQuery<LCObject> helloQuery = new LCQuery<LCObject>("Hello"); LCQuery<LCObject> helloQuery = new LCQuery<LCObject>("Hello");
helloQuery.WhereEqualTo("objectValue", world); helloQuery.WhereEqualTo("objectValue", queryWorld);
LCObject hello = await helloQuery.First(); LCObject queryHello = await helloQuery.First();
TestContext.WriteLine(hello.ObjectId); TestContext.WriteLine(queryHello.ObjectId);
Assert.AreEqual(hello.ObjectId, "5e0d55aedd3c13006a53cd87"); Assert.AreEqual(queryHello.ObjectId, hello.ObjectId);
} }
[Test] [Test]

View File

@ -4,23 +4,18 @@ using System.Collections.ObjectModel;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class RelationTest { public class RelationTest : BaseTest {
[SetUp] private LCObject parent;
public void SetUp() { private LCObject c1;
Utils.SetUp(); private LCObject c2;
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
[Order(0)]
public async Task AddAndRemove() { public async Task AddAndRemove() {
LCObject parent = new LCObject("Parent"); parent = new LCObject("Parent");
LCObject c1 = new LCObject("Child"); c1 = new LCObject("Child");
parent.AddRelation("children", c1); parent.AddRelation("children", c1);
LCObject c2 = new LCObject("Child"); c2 = new LCObject("Child");
parent.AddRelation("children", c2); parent.AddRelation("children", c2);
await parent.Save(); await parent.Save();
@ -40,10 +35,11 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(1)]
public async Task Query() { public async Task Query() {
LCQuery<LCObject> query = new LCQuery<LCObject>("Parent"); LCQuery<LCObject> query = new LCQuery<LCObject>("Parent");
LCObject parent = await query.Get("5e13112021b47e0070ed0922"); LCObject queryParent = await query.Get(parent.ObjectId);
LCRelation<LCObject> relation = parent["children"] as LCRelation<LCObject>; LCRelation<LCObject> relation = queryParent["children"] as LCRelation<LCObject>;
TestContext.WriteLine(relation.Key); TestContext.WriteLine(relation.Key);
TestContext.WriteLine(relation.Parent); TestContext.WriteLine(relation.Parent);

View File

@ -5,23 +5,13 @@ using System.Threading.Tasks;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
[TestFixture] public class RoleTest : BaseTest {
public class RoleTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
public async Task NewRole() { public async Task NewRole() {
LCUser currentUser = await LCUser.Login("game", "play"); LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);
LCACL acl = new LCACL(); LCACL acl = new LCACL {
acl.PublicReadAccess = true; PublicReadAccess = true
};
acl.SetUserWriteAccess(currentUser, true); acl.SetUserWriteAccess(currentUser, true);
string name = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}"; string name = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
LCRole role = LCRole.Create(name, acl); LCRole role = LCRole.Create(name, acl);

View File

@ -4,20 +4,10 @@ using System.Threading.Tasks;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class SMSTest { public class SMSTest : BaseTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
//[Test] //[Test]
public async Task RequestSMS() { public async Task RequestSMS() {
await LCSMSClient.RequestSMSCode("15101006007", await LCSMSClient.RequestSMSCode(TestPhone,
template: "test_template", template: "test_template",
signature: "flutter-test", signature: "flutter-test",
variables: new Dictionary<string, object> { variables: new Dictionary<string, object> {
@ -27,12 +17,12 @@ namespace Storage.Test {
//[Test] //[Test]
public async Task RequestVoice() { public async Task RequestVoice() {
await LCSMSClient.RequestVoiceCode("+8615101006007"); await LCSMSClient.RequestVoiceCode(TestPhone);
} }
//[Test] [Test]
public async Task Verify() { public async Task Verify() {
await LCSMSClient.VerifyMobilePhone("15101006007", ""); await LCSMSClient.VerifyMobilePhone(TestPhone, TestSMSCode);
} }
} }
} }

View File

@ -6,21 +6,11 @@ using System.Collections.ObjectModel;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
public class StatusTest { public class StatusTest : BaseTest {
private LCUser user1; private LCUser user1;
private LCUser user2; private LCUser user2;
private LCUser user3; private LCUser user3;
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
[Order(0)] [Order(0)]
public async Task Init() { public async Task Init() {

View File

@ -1,55 +1,12 @@
using NUnit.Framework; using NUnit.Framework;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using LeanCloud;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace Storage.Test { namespace Storage.Test {
internal class Hello : LCObject { public class SubClassTest : BaseTest {
internal World World => this["objectValue"] as World;
internal Hello() : base("Hello") { }
}
internal class World : LCObject {
internal string Content {
get {
return this["content"] as string;
} set {
this["content"] = value;
}
}
internal World() : base("World") { }
}
internal class Account : LCObject {
internal int Balance {
get {
return (int)this["balance"];
} set {
this["balance"] = value;
}
}
internal Account() : base("Account") { }
}
[TestFixture]
public class SubClassTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
public async Task Create() { public async Task Create() {
LCObject.RegisterSubclass<Account>("Account", () => new Account());
Account account = new Account(); Account account = new Account();
account.Balance = 1000; account.Balance = 1000;
await account.Save(); await account.Save();
@ -59,7 +16,6 @@ namespace Storage.Test {
[Test] [Test]
public async Task Query() { public async Task Query() {
LCObject.RegisterSubclass<Account>("Account", () => new Account());
LCQuery<Account> query = new LCQuery<Account>("Account"); LCQuery<Account> query = new LCQuery<Account>("Account");
query.WhereGreaterThan("balance", 500); query.WhereGreaterThan("balance", 500);
ReadOnlyCollection<Account> list = await query.Find(); ReadOnlyCollection<Account> list = await query.Find();
@ -72,29 +28,11 @@ namespace Storage.Test {
[Test] [Test]
public async Task Delete() { public async Task Delete() {
LCObject.RegisterSubclass<Account>("Account", () => new Account());
Account account = new Account() { Account account = new Account() {
Balance = 1024 Balance = 1024
}; };
await account.Save(); await account.Save();
await account.Delete(); await account.Delete();
} }
[Test]
public async Task Include() {
LCObject.RegisterSubclass<Hello>("Hello", () => new Hello());
LCObject.RegisterSubclass<World>("World", () => new World());
LCQuery<Hello> helloQuery = new LCQuery<Hello>("Hello");
helloQuery.Include("objectValue");
Hello hello = await helloQuery.Get("5e0d55aedd3c13006a53cd87");
World world = hello.World;
TestContext.WriteLine(hello.ObjectId);
Assert.AreEqual(hello.ObjectId, "5e0d55aedd3c13006a53cd87");
TestContext.WriteLine(world.ObjectId);
Assert.AreEqual(world.ObjectId, "5e0d55ae21460d006a1ec931");
Assert.AreEqual(world.Content, "7788");
}
} }
} }

View File

@ -7,18 +7,9 @@ using LeanCloud.Storage;
using LC.Newtonsoft.Json; using LC.Newtonsoft.Json;
namespace Storage.Test { namespace Storage.Test {
public class UserTest { public class UserTest : BaseTest {
[SetUp]
public void SetUp() {
Utils.SetUp();
}
[TearDown]
public void TearDown() {
Utils.TearDown();
}
[Test] [Test]
[Order(0)]
public async Task SignUp() { public async Task SignUp() {
LCUser user = new LCUser(); LCUser user = new LCUser();
long unixTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); long unixTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
@ -26,11 +17,11 @@ namespace Storage.Test {
user.Password = "world"; user.Password = "world";
string email = $"{unixTime}@qq.com"; string email = $"{unixTime}@qq.com";
user.Email = email; user.Email = email;
Random random = new Random(); //Random random = new Random();
string mobile = $"151{random.Next(10000000, 99999999)}"; //string mobile = $"151{random.Next(10000000, 99999999)}";
user.Mobile = mobile; //user.Mobile = mobile;
await user.SignUp(); await user.SignUp();
TestContext.WriteLine(user.Username); TestContext.WriteLine(user.Username);
TestContext.WriteLine(user.Password); TestContext.WriteLine(user.Password);
@ -42,40 +33,63 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(1)]
public async Task Login() { public async Task Login() {
await LCUser.Login("hello", "world"); try {
await LCUser.Login(TestPhone, TestPhone);
} catch (LCException e) {
if (e.Code == 211) {
LCUser user = new LCUser {
Username = TestPhone,
Password = TestPhone,
Mobile = TestPhone,
Email = GetTestEmail()
};
await user.SignUp();
} else {
throw e;
}
}
await LCUser.Login(TestPhone, TestPhone);
LCUser current = await LCUser.GetCurrent(); LCUser current = await LCUser.GetCurrent();
Assert.NotNull(current.ObjectId); Assert.NotNull(current.ObjectId);
Assert.IsFalse(current.EmailVerified); Assert.IsFalse(current.EmailVerified);
Assert.IsFalse(!current.MobileVerified); Assert.IsTrue(current.MobileVerified);
Assert.AreEqual(current.Mobile, "15101006007"); Assert.AreEqual(current.Mobile, TestPhone);
} }
[Test] [Test]
[Order(2)]
public async Task LoginByEmail() { public async Task LoginByEmail() {
await LCUser.LoginByEmail("171253484@qq.com", "world"); await LCUser.LoginByEmail(GetTestEmail(), TestPhone);
LCUser current = await LCUser.GetCurrent(); LCUser current = await LCUser.GetCurrent();
Assert.NotNull(current.ObjectId); Assert.NotNull(current.ObjectId);
} }
[Test] [Test]
[Order(3)]
public async Task LoginBySessionToken() { public async Task LoginBySessionToken() {
LCUser user = await LCUser.Login(TestPhone, TestPhone);
string sessionToken = user.SessionToken;
await LCUser.Logout(); await LCUser.Logout();
string sessionToken = "luo2fpl4qij2050e7enqfz173";
await LCUser.BecomeWithSessionToken(sessionToken); await LCUser.BecomeWithSessionToken(sessionToken);
LCUser current = await LCUser.GetCurrent(); LCUser current = await LCUser.GetCurrent();
Assert.NotNull(current.ObjectId); Assert.NotNull(current.ObjectId);
} }
[Test] [Test]
[Order(4)]
public async Task RelateObject() { public async Task RelateObject() {
LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "world"); LCUser user = await LCUser.LoginByMobilePhoneNumber(TestPhone, TestPhone);
LCObject account = new LCObject("Account"); Account account = new Account();
account["user"] = user; account.User = user;
await account.Save(); await account.Save();
} }
[Test] [Test]
[Order(5)]
public async Task LoginAnonymous() { public async Task LoginAnonymous() {
LCUser user = await LCUser.LoginAnonymously(); LCUser user = await LCUser.LoginAnonymously();
Assert.NotNull(user.ObjectId); Assert.NotNull(user.ObjectId);
@ -83,6 +97,7 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(6)]
public async Task LoginWithAuthData() { public async Task LoginWithAuthData() {
string uuid = Guid.NewGuid().ToString(); string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> { Dictionary<string, object> authData = new Dictionary<string, object> {
@ -109,6 +124,7 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(7)]
public async Task AssociateAuthData() { public async Task AssociateAuthData() {
string uuid = Guid.NewGuid().ToString(); string uuid = Guid.NewGuid().ToString();
LCUser currentUser = await LCUser.Login("hello", "world"); LCUser currentUser = await LCUser.Login("hello", "world");
@ -123,12 +139,14 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(8)]
public async Task DisassociateAuthData() { public async Task DisassociateAuthData() {
LCUser currentUser = await LCUser.Login("hello", "world"); LCUser currentUser = await LCUser.Login("hello", "world");
await currentUser.DisassociateWithAuthData("weixin"); await currentUser.DisassociateWithAuthData("weixin");
} }
[Test] [Test]
[Order(9)]
public async Task IsAuthenticated() { public async Task IsAuthenticated() {
LCUser currentUser = await LCUser.Login("hello", "world"); LCUser currentUser = await LCUser.Login("hello", "world");
bool isAuthenticated = await currentUser.IsAuthenticated(); bool isAuthenticated = await currentUser.IsAuthenticated();
@ -137,6 +155,7 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(10)]
public async Task UpdatePassword() { public async Task UpdatePassword() {
LCUser currentUser = await LCUser.Login("hello", "world"); LCUser currentUser = await LCUser.Login("hello", "world");
await currentUser.UpdatePassword("world", "newWorld"); await currentUser.UpdatePassword("world", "newWorld");
@ -144,6 +163,7 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(11)]
public async Task LoginWithAuthDataWithUnionId() { public async Task LoginWithAuthDataWithUnionId() {
string uuid = Guid.NewGuid().ToString(); string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> { Dictionary<string, object> authData = new Dictionary<string, object> {
@ -174,8 +194,9 @@ namespace Storage.Test {
} }
[Test] [Test]
[Order(12)]
public async Task AssociateAuthDataWithUnionId() { public async Task AssociateAuthDataWithUnionId() {
LCUser currentUser = await LCUser.Login("hello", "world"); LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);
string uuid = Guid.NewGuid().ToString(); string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> { Dictionary<string, object> authData = new Dictionary<string, object> {
{ "expires_in", 7200 }, { "expires_in", 7200 },
@ -188,22 +209,24 @@ namespace Storage.Test {
// 手动测试 // 手动测试
//[Test] [Test]
//public async Task LoginByMobile() { [Order(13)]
// LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "112358"); public async Task LoginByMobile() {
// Assert.NotNull(user.ObjectId); LCUser user = await LCUser.LoginByMobilePhoneNumber(TestPhone, TestPhone);
//} Assert.NotNull(user.ObjectId);
}
//[Test] //[Test]
//public async Task RequestLoginSMSCode() { //public async Task RequestLoginSMSCode() {
// await LCUser.RequestLoginSMSCode("15101006007"); // await LCUser.RequestLoginSMSCode("15101006007");
//} //}
//[Test] [Test]
//public async Task LoginBySMSCode() { [Order(14)]
// LCUser user = await LCUser.LoginBySMSCode("15101006007", "194998"); public async Task LoginBySMSCode() {
// Assert.NotNull(user.ObjectId); LCUser user = await LCUser.LoginBySMSCode(TestPhone, TestSMSCode);
//} Assert.NotNull(user.ObjectId);
}
//[Test] //[Test]
//public async Task RequestEmailVerify() { //public async Task RequestEmailVerify() {
@ -215,10 +238,11 @@ namespace Storage.Test {
// await LCUser.RequestMobilePhoneVerify("15101006007"); // await LCUser.RequestMobilePhoneVerify("15101006007");
//} //}
//[Test] [Test]
//public async Task VerifyMobile() { [Order(15)]
// await LCUser.VerifyMobilePhone("15101006007", "506993"); public async Task VerifyMobile() {
//} await LCUser.VerifyMobilePhone(TestPhone, TestSMSCode);
}
//[Test] //[Test]
//public async Task RequestResetPasswordBySMSCode() { //public async Task RequestResetPasswordBySMSCode() {
@ -230,19 +254,21 @@ namespace Storage.Test {
// await LCUser.ResetPasswordBySmsCode("15101006007", "732552", "112358"); // await LCUser.ResetPasswordBySmsCode("15101006007", "732552", "112358");
//} //}
[Test] //[Test]
public async Task RequestSMSCodeForUpdatingPhoneNumber() { //public async Task RequestSMSCodeForUpdatingPhoneNumber() {
await LCUser.Login("hello", "world"); // await LCUser.Login(TestPhone, TestPhone);
await LCUser.RequestSMSCodeForUpdatingPhoneNumber("15101006007"); // await LCUser.RequestSMSCodeForUpdatingPhoneNumber(TestPhone);
} //}
[Test] [Test]
[Order(16)]
public async Task VerifyCodeForUpdatingPhoneNumber() { public async Task VerifyCodeForUpdatingPhoneNumber() {
await LCUser.Login("hello", "world"); await LCUser.Login(TestPhone, TestPhone);
await LCUser.VerifyCodeForUpdatingPhoneNumber("15101006007", "969327"); await LCUser.VerifyCodeForUpdatingPhoneNumber(TestPhone, TestSMSCode);
} }
[Test] [Test]
[Order(17)]
public async Task AuthData() { public async Task AuthData() {
string uuid = Guid.NewGuid().ToString(); string uuid = Guid.NewGuid().ToString();
Dictionary<string, object> authData = new Dictionary<string, object> { Dictionary<string, object> authData = new Dictionary<string, object> {
@ -270,5 +296,9 @@ namespace Storage.Test {
TestContext.WriteLine(JsonConvert.SerializeObject(currentUser.AuthData)); TestContext.WriteLine(JsonConvert.SerializeObject(currentUser.AuthData));
} }
} }
private string GetTestEmail() {
return $"{TestPhone}@leancloud.rocks";
}
} }
} }

View File

@ -1,37 +0,0 @@
using NUnit.Framework;
using LeanCloud;
namespace Storage.Test {
public static class Utils {
internal const string AppId = "ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz";
internal const string AppKey = "NUKmuRbdAhg1vrb2wexYo1jo";
internal const string MasterKey = "pyvbNSh5jXsuFQ3C8EgnIdhw";
internal const string AppServer = "https://ikggdre2.lc-cn-n1-shared.com";
internal static void Print(LCLogLevel level, string info) {
switch (level) {
case LCLogLevel.Debug:
TestContext.Out.WriteLine($"[DEBUG] {info}");
break;
case LCLogLevel.Warn:
TestContext.Out.WriteLine($"[WARNING] {info}");
break;
case LCLogLevel.Error:
TestContext.Out.WriteLine($"[ERROR] {info}");
break;
default:
TestContext.Out.WriteLine(info);
break;
}
}
internal static void SetUp() {
LCLogger.LogDelegate += Print;
LCApplication.Initialize(AppId, AppKey, AppServer);
}
internal static void TearDown() {
LCLogger.LogDelegate -= Print;
}
}
}