云库增加 AI识图,缓存,我的云库收藏增加安全标志
调用外部API 扣费
This commit is contained in:
1 parent
7c29e57623
commit
150e8644b7
49 files changed
+1069
-28
No files matched your search
@@ -0,0 +1,61 @@
|
||||
using MAX.Framework.Commons;
|
||||
using Store.Users.Entities;
|
||||
using Store.Users.Repositories;
|
||||
using Store.Users.Services;
|
||||
|
||||
namespace Store.Users.Tests;
|
||||
|
||||
/// <summary>验证主账号解析及无效父账号的继承边界。</summary>
|
||||
public sealed class UserRepositoryTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task ChildFees_MatchMainAccount_IncludingUnsetValues(bool unset)
|
||||
{
|
||||
using var context = new UserTestContext();
|
||||
decimal? fee = unset ? null : 0.5m;
|
||||
await context.Db.Update<UserEntity>().Set(u => u.PostagePerOrder, fee)
|
||||
.Set(u => u.RefundPostagePerOrder, fee).Set(u => u.GiftOemAmountPerOrder, fee)
|
||||
.Set(u => u.SyncLogisticsPerOrder, fee).Set(u => u.ShopPointsPerMonth, 45)
|
||||
.Where(u => u.Id == context.Main.Id).ExecuteAffrowsAsync();
|
||||
|
||||
var main = await context.Query.GetUser("main");
|
||||
var child = await context.Query.GetUser("child");
|
||||
Assert.Equal(main.PostagePerOrder, child.PostagePerOrder);
|
||||
Assert.Equal(main.RefundPostagePerOrder, child.RefundPostagePerOrder);
|
||||
Assert.Equal(main.GiftOemAmountPerOrder, child.GiftOemAmountPerOrder);
|
||||
Assert.Equal(main.SyncLogisticsPerOrder, child.SyncLogisticsPerOrder);
|
||||
Assert.Equal(45, child.ShopPointsPerMonth);
|
||||
Assert.Equal(30, (await context.Read("child")).ShopPointsPerMonth);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("main", "main")]
|
||||
[InlineData("child", "main")]
|
||||
[InlineData("missing", null)]
|
||||
public async Task GetMainUser_ResolvesOwner(string userName, string? expected)
|
||||
{
|
||||
using var context = new UserTestContext();
|
||||
var repository = (IUserRepository)Activator.CreateInstance(
|
||||
typeof(UserManagementService).Assembly.GetType("Store.Users.Repositories.UserRepository", true)!, context.Db)!;
|
||||
|
||||
Assert.Equal(expected, (await repository.GetMainUser(userName))?.UserName);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("missing")]
|
||||
[InlineData("child")]
|
||||
[InlineData("")]
|
||||
public async Task InvalidParent_IsRejectedByBothQueries(string parent)
|
||||
{
|
||||
using var context = new UserTestContext();
|
||||
await context.Db.Update<UserEntity>().Set(u => u.ParentUserName, parent)
|
||||
.Where(u => u.Id == context.Child.Id).ExecuteAffrowsAsync();
|
||||
var repository = (IUserRepository)Activator.CreateInstance(
|
||||
typeof(UserManagementService).Assembly.GetType("Store.Users.Repositories.UserRepository", true)!, context.Db)!;
|
||||
|
||||
await Assert.ThrowsAsync<AppException>(() => repository.GetUser("child"));
|
||||
await Assert.ThrowsAsync<AppException>(() => repository.GetMainUser("child"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user