From eda7dd43bb57ff6731455b366e0acdd4b73467bd Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 2 Sep 2019 14:23:23 +0800 Subject: [PATCH] * RoleTest.cs: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * SubClassTest.cs: test: 增加子类化测试 --- Storage/Storage.Test/RoleTest.cs | 1 + Storage/Storage.Test/SubClassTest.cs | 49 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Storage/Storage.Test/SubClassTest.cs diff --git a/Storage/Storage.Test/RoleTest.cs b/Storage/Storage.Test/RoleTest.cs index 9056627..27c6347 100644 --- a/Storage/Storage.Test/RoleTest.cs +++ b/Storage/Storage.Test/RoleTest.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using LeanCloud; namespace LeanCloudTests { + [TestFixture] public class RoleTest { [SetUp] public void SetUp() { diff --git a/Storage/Storage.Test/SubClassTest.cs b/Storage/Storage.Test/SubClassTest.cs new file mode 100644 index 0000000..ca24f1c --- /dev/null +++ b/Storage/Storage.Test/SubClassTest.cs @@ -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("Name"); + } + set { + SetProperty(value, "Name"); + } + } + + [AVFieldName("balance")] + public int Balance { + get { + return GetProperty("Balance"); + } + set { + SetProperty(value, "Balance"); + } + } + } + + [TestFixture] + public class SubClassTest { + [SetUp] + public void SetUp() { + Utils.InitNorthChina(true); + } + + [Test] + public async Task SubClass() { + AVObject.RegisterSubclass(); + AVQuery query = new AVQuery(); + IEnumerable 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}"); + } + } + } +}