* Utils.cs:

* AVObject.cs:
* CloudFunctionTest.cs:

* ObjectSubclassingController.cs: chore: 测试云函数
oneRain 2019-08-28 18:19:26 +08:00
parent 7a5aef733d
commit 9d932f0f0b
4 changed files with 34 additions and 12 deletions

View File

@ -0,0 +1,22 @@
using NUnit.Framework;
using LeanCloud;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LeanCloudTests {
public class CloudFunctionTest {
[SetUp]
public void SetUp() {
Utils.InitNorthChina();
}
[Test]
public async Task Hello() {
AVClient.UseProduction = true;
string result = await AVCloud.CallFunctionAsync<string>("hello", new Dictionary<string, object> {
{ "word", "world" }
});
TestContext.Out.WriteLine($"resutlt: {result}");
}
}
}

View File

@ -6,34 +6,35 @@ namespace LeanCloudTests {
public static class Utils { public static class Utils {
public static void InitNorthChina(bool master = false) { public static void InitNorthChina(bool master = false) {
if (master) { if (master) {
Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com", "qKH9ryRagHKvXeRRVkiUiHeb"); Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com", "https://avoscloud.com", "qKH9ryRagHKvXeRRVkiUiHeb");
} else { } else {
Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com"); Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com", "https://avoscloud.com");
} }
} }
public static void InitEastChina(bool master = false) { public static void InitEastChina(bool master = false) {
if (master) { if (master) {
Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com", "eqEp4n89h4zanWFskDDpIwL4"); Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com", "https://4eTwHdYh.engine.lncldapi.com", "eqEp4n89h4zanWFskDDpIwL4");
} else { } else {
Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com"); Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com", "https://4eTwHdYh.engine.lncldapi.com");
} }
} }
public static void InitUS(bool master = false) { public static void InitUS(bool master = false) {
if (master) { if (master) {
Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com", "Ahb1wdFLwMgKwEaEicHRXbCY"); Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com", "https://MFAS1GnO.engine.lncldglobal.com", "Ahb1wdFLwMgKwEaEicHRXbCY");
} else { } else {
Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com"); Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com", "https://MFAS1GnO.engine.lncldglobal.com");
} }
} }
static void Init(string appId, string appKey, string apiServer, string masterKey = null) { static void Init(string appId, string appKey, string apiServer, string engineServer, string masterKey = null) {
AVClient.Initialize(new AVClient.Configuration { AVClient.Initialize(new AVClient.Configuration {
ApplicationId = appId, ApplicationId = appId,
ApplicationKey = appKey, ApplicationKey = appKey,
MasterKey = masterKey, MasterKey = masterKey,
ApiServer = apiServer ApiServer = apiServer,
EngineServer = engineServer,
}); });
AVClient.UseMasterKey = !string.IsNullOrEmpty(masterKey); AVClient.UseMasterKey = !string.IsNullOrEmpty(masterKey);
AVClient.HttpLog(TestContext.Out.WriteLine); AVClient.HttpLog(TestContext.Out.WriteLine);

View File

@ -126,9 +126,8 @@ namespace LeanCloud.Storage.Internal {
public IDictionary<string, string> GetPropertyMappings(string className) { public IDictionary<string, string> GetPropertyMappings(string className) {
mutex.EnterReadLock(); mutex.EnterReadLock();
registeredSubclasses.TryGetValue(className, out info); if (!registeredSubclasses.TryGetValue(className, out ObjectSubclassInfo info)) {
if (info == null) { _ = registeredSubclasses.TryGetValue(avObjectClassName, out info);
registeredSubclasses.TryGetValue(avObjectClassName, out info);
} }
mutex.ExitReadLock(); mutex.ExitReadLock();

View File

@ -210,7 +210,7 @@ namespace LeanCloud {
} }
private static string GetFieldForPropertyName(string className, string propertyName) { private static string GetFieldForPropertyName(string className, string propertyName) {
SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out fieldName); SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out string fieldName);
return fieldName; return fieldName;
} }