forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpTest.cs
More file actions
84 lines (68 loc) · 2.59 KB
/
HttpTest.cs
File metadata and controls
84 lines (68 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using NUnit.Framework;
using System.Application.Services;
namespace System.Application;
[TestFixture]
public class HttpTest
{
///// <summary>
///// 测试图片下载缓存,同一个图片地址,多次请求,仅发送一次,且优先从缓存中加载图片
///// </summary>
//[Test]
//public void GetImage()
//{
// const string api_base = "https://localhost:5001/";
// var images = new[] {
// "images/icons/company.png",
// "images/icons/GitHub-Mark-120px-plus.png",
// "images/icons/icon.png",
// "images/company.png",
// "images/icons/company.png",
// "images/icons/GitHub-Mark-120px-plus.png",
// "images/icons/logo.png",
// "images/company.png",
// "images/icons/icon.png",
// "images/icons/icon.png",
// "images/icons/steam.png" };
// var tasks = images.Select(Handle).ToArray();
// Task.WaitAll(tasks);
// TestContext.WriteLine("OK");
// static async Task Handle(string requestUri)
// {
// var tid = Environment.CurrentManagedThreadId;
// var result = await IHttpService.Instance.GetImageAsync(
// api_base + requestUri, ImageChannelType.SteamAvatars);
// var tid2 = Environment.CurrentManagedThreadId;
// TestContext.WriteLine($"({tid}-{tid2})requestUri: {requestUri}, length: {result?.Length}");
// }
//}
#if DEBUG
///// <summary>
///// 测试 登录与注册 接口,先开服务端(私有),再测试
///// </summary>
///// <returns></returns>
//[Test]
//public async Task LoginOrRegister()
//{
// var client = ICloudServiceClient.Instance;
// var req1 = new SendSmsRequest
// {
// PhoneNumber = "18611112222",
// Type = SmsCodeType.LoginOrRegister,
// };
// var rsp1 = await client.AuthMessage.SendSms(req1);
// Assert.IsTrue(rsp1.IsSuccess);
// var req2 = new LoginOrRegisterRequest
// {
// PhoneNumber = req1.PhoneNumber,
// SmsCode = "666666",
// };
// var rsp2 = await ICloudServiceClient.Instance.Account.LoginOrRegister(req2);
// Assert.IsTrue(rsp2.IsSuccess);
// var isLoginOrRegister = rsp2.Content.ThrowIsNull(nameof(rsp2.Content)).IsLoginOrRegister;
// TestContext.WriteLine($"isLoginOrRegister: {isLoginOrRegister}");
// var jsonStr = Serializable2.S(rsp2.Content);
// TestContext.WriteLine("jsonStr: ");
// TestContext.WriteLine(jsonStr);
//}
#endif
}