You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB
C#

10 months ago
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
10 months ago
using Xunit;
namespace Ds.WMS.Test;
public class UnitTest1
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
// private readonly ICommonService _commonService;
public UnitTest1(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
// _commonService = _serviceProvider.GetRequiredService<ICommonService>();
}
10 months ago
[Fact]
public void Test1()
{
var temp = EntityUtil.getEntity("SysUser");
Assert.True(true);
}
10 months ago
[Fact]
public void GetEntity()
{
var info = db.Queryable<object>().AS("sys_user").Where("Id=@Id", new { Id = 1745261353939111936 }).First();
Assert.True(info.IsNotNull());
10 months ago
}
10 months ago
[Fact]
public void ConstTest()
{
ConstUtil.GetConstantField();
Assert.True(true);
}
[Fact]
public void DataRuleTest()
{
// var query = _commonService.GetDataRuleFilter<SysUser>();
var query = GetDataRuleFilter<SysUser>();
Assert.True(true);
}
public ISugarQueryable<T> GetDataRuleFilter<T>()
{
// var userInfo = db.Queryable<SysUser>().First(x => x.Id == long.Parse(user.UserId));
// if (userInfo.UserType == 0)
// {
// return db.Queryable<T>(); //超级管理员特权
// }
var moduleName = typeof(T).Name;
// var rule = db.Queryable<SysDataRule>().First(u => u.PermissionName == moduleName);
// if (rule == null) return db.Queryable<T>(); //没有设置数据规则,那么视为该资源允许被任何主体查看
return db.Queryable<T>();
}
10 months ago
}