chore: 简单的用户接口测试

oneRain 2019-08-07 17:41:36 +08:00
parent e1c57e5bc3
commit c994aad93e
2 changed files with 37 additions and 1 deletions

View File

@ -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");
}
}
}

View File

@ -66,7 +66,7 @@ namespace LeanCloud.Storage.Internal {
// 错误处理
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(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 {