* CloudFunctionTest.cs:
* AVCloudCodeController.cs: fix: 修复云函数无参数时的 bug
parent
9d932f0f0b
commit
e4681cfa40
|
|
@ -16,6 +16,16 @@ namespace LeanCloudTests {
|
||||||
string result = await AVCloud.CallFunctionAsync<string>("hello", new Dictionary<string, object> {
|
string result = await AVCloud.CallFunctionAsync<string>("hello", new Dictionary<string, object> {
|
||||||
{ "word", "world" }
|
{ "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}");
|
TestContext.Out.WriteLine($"resutlt: {result}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ namespace LeanCloud.Storage.Internal {
|
||||||
var command = new EngineCommand {
|
var command = new EngineCommand {
|
||||||
Path = $"functions/{Uri.EscapeUriString(name)}",
|
Path = $"functions/{Uri.EscapeUriString(name)}",
|
||||||
Method = HttpMethod.Post,
|
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>;
|
var decoded = AVDecoder.Instance.Decode(t.Result.Item2) as IDictionary<string, object>;
|
||||||
if (!decoded.ContainsKey("result")) {
|
if (!decoded.ContainsKey("result")) {
|
||||||
return default;
|
return default;
|
||||||
|
|
@ -28,7 +28,7 @@ namespace LeanCloud.Storage.Internal {
|
||||||
var command = new EngineCommand {
|
var command = new EngineCommand {
|
||||||
Path = $"call/{Uri.EscapeUriString(name)}",
|
Path = $"call/{Uri.EscapeUriString(name)}",
|
||||||
Method = HttpMethod.Post,
|
Method = HttpMethod.Post,
|
||||||
Content = parameters
|
Content = parameters ?? new Dictionary<string, object>()
|
||||||
};
|
};
|
||||||
return AVPlugins.Instance.CommandRunner.RunCommandAsync<IDictionary<string, object>>(command, 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>;
|
var decoded = AVDecoder.Instance.Decode(t.Result.Item2) as IDictionary<string, object>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue