* RoleTest.cs:
* SubClassTest.cs: test: 增加子类化测试
parent
7980d47168
commit
eda7dd43bb
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||
using LeanCloud;
|
||||
|
||||
namespace LeanCloudTests {
|
||||
[TestFixture]
|
||||
public class RoleTest {
|
||||
[SetUp]
|
||||
public void SetUp() {
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue