* CloudFunctionTest.cs:

* AVCloudCodeController.cs: fix: 修复云函数无参数时的 bug
oneRain 2019-08-29 11:03:49 +08:00
parent 9d932f0f0b
commit e4681cfa40
2 changed files with 13 additions and 3 deletions

View File

@ -16,6 +16,16 @@ namespace LeanCloudTests {
string result = await AVCloud.CallFunctionAsync<string>("hello", new Dictionary<string, object> {
{ "word", "world" }
});
Assert.AreEqual(result, "hello, world");
TestContext.Out.WriteLine($"resutlt: {result}");
}
[Test]
public async Task GetUsernameInCloud() {
AVClient.UseProduction = true;
await AVUser.LogInAsync("111111", "111111");
string result = await AVCloud.CallFunctionAsync<string>("getUsername");
Assert.AreEqual(result, "111111");
TestContext.Out.WriteLine($"resutlt: {result}");
}
}

View File

@ -13,9 +13,9 @@ namespace LeanCloud.Storage.Internal {
var command = new EngineCommand {
Path = $"functions/{Uri.EscapeUriString(name)}",
Method = HttpMethod.Post,
Content = parameters
Content = parameters ?? new Dictionary<string, object>()
};
return AVPlugins.Instance.CommandRunner.RunCommandAsync<IDictionary<string, object>>(command, cancellationToken: cancellationToken).OnSuccess(t => {
return AVPlugins.Instance.CommandRunner.RunCommandAsync<IDictionary<string, object>>(command, cancellationToken).OnSuccess(t => {
var decoded = AVDecoder.Instance.Decode(t.Result.Item2) as IDictionary<string, object>;
if (!decoded.ContainsKey("result")) {
return default;
@ -28,7 +28,7 @@ namespace LeanCloud.Storage.Internal {
var command = new EngineCommand {
Path = $"call/{Uri.EscapeUriString(name)}",
Method = HttpMethod.Post,
Content = parameters
Content = parameters ?? new Dictionary<string, object>()
};
return AVPlugins.Instance.CommandRunner.RunCommandAsync<IDictionary<string, object>>(command, cancellationToken).OnSuccess(t => {
var decoded = AVDecoder.Instance.Decode(t.Result.Item2) as IDictionary<string, object>;