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; 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(); // _commonService = _serviceProvider.GetRequiredService(); } [Fact] public void Test1() { var temp = EntityUtil.getEntity("SysUser"); Assert.True(true); } [Fact] public void GetEntity() { var info = db.Queryable().AS("sys_user").Where("Id=@Id", new { Id = 1745261353939111936 }).First(); Assert.True(info.IsNotNull()); } [Fact] public void ConstTest() { ConstUtil.GetConstantField(); Assert.True(true); } [Fact] public void DataRuleTest() { // var query = _commonService.GetDataRuleFilter(); var query = GetDataRuleFilter(); Assert.True(true); } public ISugarQueryable GetDataRuleFilter() { // var userInfo = db.Queryable().First(x => x.Id == long.Parse(user.UserId)); // if (userInfo.UserType == 0) // { // return db.Queryable(); //超级管理员特权 // } var moduleName = typeof(T).Name; // var rule = db.Queryable().First(u => u.PermissionName == moduleName); // if (rule == null) return db.Queryable(); //没有设置数据规则,那么视为该资源允许被任何主体查看 return db.Queryable(); } }