* ObjectControllerTests.cs:

* AVObject.cs: test: 测试 Object 的 fetch 方法
oneRain 2019-08-27 17:27:46 +08:00
parent 65b54eb5d3
commit 548d2314a1
2 changed files with 12 additions and 8 deletions

View File

@ -7,12 +7,7 @@ namespace LeanCloudTests {
public class ObjectControllerTests { public class ObjectControllerTests {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {
AVClient.Initialize(new AVClient.Configuration { Utils.InitNorthChina();
ApplicationId = "BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz",
ApplicationKey = "pbf6Nk5seyjilexdpyrPwjSp",
ApiServer = "https://avoscloud.com"
});
AVClient.HttpLog(TestContext.Out.WriteLine);
} }
[Test] [Test]
@ -26,5 +21,14 @@ namespace LeanCloudTests {
Assert.NotNull(obj.CreatedAt); Assert.NotNull(obj.CreatedAt);
Assert.NotNull(obj.UpdatedAt); Assert.NotNull(obj.UpdatedAt);
} }
[Test]
public async Task ObjectFetch() {
AVObject obj = AVObject.CreateWithoutData("Todo", "5d5f6039d5de2b006cf29c8f");
await obj.FetchAsync();
Assert.NotNull(obj["title"]);
Assert.NotNull(obj["content"]);
TestContext.Out.WriteLine($"{obj["title"]}, {obj["content"]}");
}
} }
} }

View File

@ -621,7 +621,7 @@ string propertyName
queryString = new Dictionary<string, object>(); queryString = new Dictionary<string, object>();
} }
return ObjectController.FetchAsync(state, queryString, AVUser.CurrentUser.SessionToken, cancellationToken); return ObjectController.FetchAsync(state, queryString, AVUser.CurrentUser?.SessionToken, cancellationToken);
}).Unwrap().OnSuccess(t => { }).Unwrap().OnSuccess(t => {
HandleFetchResult(t.Result); HandleFetchResult(t.Result);
return this; return this;