37 lines
1.3 KiB
C#
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, []));
|
|
}
|
|
}
|