50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
|
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}");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|