* RoleTest.cs:

* SubClassTest.cs: test: 增加子类化测试
oneRain 2019-09-02 14:23:23 +08:00
parent 7980d47168
commit eda7dd43bb
2 changed files with 50 additions and 0 deletions

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using LeanCloud;
namespace LeanCloudTests {
[TestFixture]
public class RoleTest {
[SetUp]
public void SetUp() {

View File

@ -0,0 +1,49 @@
using NUnit.Framework;
using LeanCloud;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace LeanCloudTests {
[AVClassName("Account")]
public class Account : AVObject {
[AVFieldName("name")]
public string Name {
get {
return GetProperty<string>("Name");
}
set {
SetProperty(value, "Name");
}
}
[AVFieldName("balance")]
public int Balance {
get {
return GetProperty<int>("Balance");
}
set {
SetProperty(value, "Balance");
}
}
}
[TestFixture]
public class SubClassTest {
[SetUp]
public void SetUp() {
Utils.InitNorthChina(true);
}
[Test]
public async Task SubClass() {
AVObject.RegisterSubclass<Account>();
AVQuery<Account> query = new AVQuery<Account>();
IEnumerable<Account> accountList = await query.FindAsync();
foreach (Account account in accountList) {
Assert.NotNull(account.Name);
Assert.Greater(account.Balance, 0);
TestContext.Out.WriteLine($"{account.Name}, {account.Balance}");
}
}
}
}