From c994aad93e20a4712dad80ffaf09c489e23c02d6 Mon Sep 17 00:00:00 2001 From: oneRain Date: Wed, 7 Aug 2019 17:41:36 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=AE=80=E5=8D=95=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Storage/Storage.Test/UserTest.cs | 36 +++++++++++++++++++ .../Internal/Command/AVCommandRunner.cs | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Storage/Storage.Test/UserTest.cs diff --git a/Storage/Storage.Test/UserTest.cs b/Storage/Storage.Test/UserTest.cs new file mode 100644 index 0000000..1cbd89b --- /dev/null +++ b/Storage/Storage.Test/UserTest.cs @@ -0,0 +1,36 @@ +using NUnit.Framework; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Linq; +using System; +using LeanCloud; + +namespace LeanCloudTests { + public class UserTest { + [SetUp] + public void SetUp() { + AVClient.Initialize(new AVClient.Configuration { + ApplicationId = "BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", + ApplicationKey = "pbf6Nk5seyjilexdpyrPwjSp", + ApiServer = "https://avoscloud.com" + }); + AVClient.HttpLog(TestContext.Out.WriteLine); + } + + [Test] + public async Task Register() { + AVUser user = new AVUser { + Username = $"hello_{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}", + Password = "world" + }; + await user.SignUpAsync(); + TestContext.Out.WriteLine($"{user.ObjectId} registered"); + } + + [Test] + public async Task Login() { + AVUser user = await AVUser.LogInAsync("hello", "world"); + TestContext.Out.WriteLine($"{user.ObjectId} login"); + } + } +} diff --git a/Storage/Storage/Internal/Command/AVCommandRunner.cs b/Storage/Storage/Internal/Command/AVCommandRunner.cs index 56172c0..00e0cd1 100644 --- a/Storage/Storage/Internal/Command/AVCommandRunner.cs +++ b/Storage/Storage/Internal/Command/AVCommandRunner.cs @@ -66,7 +66,7 @@ namespace LeanCloud.Storage.Internal { // 错误处理 var data = JsonConvert.DeserializeObject>(contentString, new LeanCloudJsonConverter()); if (data.TryGetValue("code", out object codeObj)) { - AVException.ErrorCode code = (AVException.ErrorCode)codeObj; + AVException.ErrorCode code = (AVException.ErrorCode)Enum.ToObject(typeof(AVException.ErrorCode), codeObj); string detail = data["error"] as string; throw new AVException(code, detail); } else {