Files
wx-win-agent/tests/node-agent/WxAgent.Core.Tests/AccountBindingMatcherOfflineSyncTests.cs
T
rogee e8abb15f68
Build web service image / build (push) Successful in 1m6s
fix: authorize verified offline data sync
2026-09-30 13:30:48 +08:00

37 lines
1.3 KiB
C#

using WxAgent.Core;
using Xunit;
namespace WxAgent.Core.Tests;
public sealed class AccountBindingMatcherOfflineSyncTests
{
[Fact]
public void PersistedBindingMustResolveToTheExpectedDatabaseAccount()
{
var databaseAccounts = new[]
{
new DatabaseAccountIdentity("root-a", "wxid-a", "Alice"),
new DatabaseAccountIdentity("root-b", "wxid-b", "Bob")
};
Assert.True(AccountBindingMatcher.IsUniquelyMatchedToAccount(
"root-a", new UiAccountIdentity("wxid-a", "Alice"), databaseAccounts));
Assert.False(AccountBindingMatcher.IsUniquelyMatchedToAccount(
"root-b", new UiAccountIdentity("wxid-a", "Alice"), databaseAccounts));
}
[Fact]
public void AmbiguousOrUnavailableDatabaseIdentityFailsClosed()
{
var ambiguousAccounts = new[]
{
new DatabaseAccountIdentity("root-a", null, "Shared"),
new DatabaseAccountIdentity("root-b", null, "Shared")
};
var boundIdentity = new UiAccountIdentity(null, "Shared");
Assert.False(AccountBindingMatcher.IsUniquelyMatchedToAccount("root-a", boundIdentity, ambiguousAccounts));
Assert.False(AccountBindingMatcher.IsUniquelyMatchedToAccount("root-a", boundIdentity, []));
}
}