115 lines
3.1 KiB
C#
115 lines
3.1 KiB
C#
using System.Net;
|
|
using System.Text;
|
|
using System.Text.Json.Nodes;
|
|
using Azure.Core;
|
|
using BeetleX.Redis.Commands;
|
|
using EI_TestProject;
|
|
using IRaCIS.Application.Contracts;
|
|
using IRaCIS.Core.Infrastructure;
|
|
using IRaCIS.Core.Infrastructure.Extention;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Org.BouncyCastle.Asn1.Crmf;
|
|
using Org.BouncyCastle.Asn1.Ocsp;
|
|
using RestSharp;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
public class UserApiTests : IDisposable
|
|
{
|
|
private RestClient _client;
|
|
|
|
|
|
|
|
public UserApiTests()
|
|
{
|
|
// 创建一个 RestClient 对象,并设置基本 URL
|
|
//client = new RestClient("http://localhost:6100");
|
|
|
|
_client = RestHelper.InitRestHelper("http://123.56.94.154:8090/api", "Admin", MD5Helper.Md5("WHxckj@2019"));
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加系统用户
|
|
/// </summary>
|
|
[Fact]
|
|
public async void Test_AddUser()
|
|
{
|
|
|
|
var url = $"/user/addUser";
|
|
|
|
var jsonBody = new JObject
|
|
{
|
|
{ "UserName", "test_hang" },
|
|
{ "LastName", "zhou" },
|
|
{ "FirstName", "hang" },
|
|
{ "Sex", 1 },
|
|
{ "EMail", "872297557@qq.com" },
|
|
{ "Phone", "" },
|
|
{ "UserTypeId", "40240000-3e2c-0016-b35f-08db1895d627" },
|
|
{ "IsZhiZhun", "" },
|
|
{ "OrganizationName", "" },
|
|
{ "DepartmentName", "" },
|
|
{ "PositionName", "" },
|
|
{ "IsTestUser", true },
|
|
{ "UserTypeEnum", 1 },
|
|
{ "BaseUrl", "http://123.56.94.154:8090/login" },
|
|
{ "RouteUrl", "http://123.56.94.154:8090/email-recompose" },
|
|
{ "RealName", string.Empty }
|
|
};
|
|
|
|
|
|
var result = await RestHelper.Post_JsonBodyRequestAsync<ResponseOutput<UserAddedReturnDTO>>(url,jsonBody);
|
|
|
|
|
|
Assert.True(result.Code != ApiResponseCodeEnum.ApiInputError && result.Code != ApiResponseCodeEnum.ProgramException);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查询系统用户
|
|
/// </summary>
|
|
[Fact]
|
|
public async void Test_GetUserList()
|
|
{
|
|
var url = $"/user/getUserList";
|
|
|
|
var jsonBody = new JObject
|
|
{
|
|
{ "RealName", string.Empty }
|
|
};
|
|
|
|
//测试删除Api
|
|
var result = await RestHelper.Post_JsonBodyRequestAsync<ResponseOutput<PageOutput<UserListDTO>>>(url, jsonBody);
|
|
|
|
Assert.True(result.Data.CurrentPageData.Count >= 0);
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 删除系统用户
|
|
/// </summary>
|
|
[Fact]
|
|
public async void Test_DeleteUser()
|
|
{
|
|
var userId = Guid.Parse("98430000-3e2c-0016-225f-08db7612c7ae");
|
|
var url = $"/user/deleteUser/{userId}";
|
|
|
|
//测试删除Api
|
|
var result = await RestHelper.DeleteRequestAsync<ResponseOutput<string>>(url);
|
|
|
|
Assert.True(result.Code != ApiResponseCodeEnum.ApiInputError && result.Code != ApiResponseCodeEnum.ProgramException);
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
{
|
|
// 在测试结束后释放资源(例如关闭网络连接等)
|
|
_client?.Dispose();
|
|
}
|
|
} |