private ITokenCacheAccessor CreateTokenCacheAccessorWithKeyPrefix( string keyPrefix, int numAccessTokens, int numRefreshTokens, int numIdTokens, int numAccounts) { var accessor = new InMemoryPartitionedUserTokenCacheAccessor(Substitute.For <ICoreLogger>(), null); for (int i = 1; i <= numAccessTokens; i++) { var item = CreateAccessTokenItem( cachedAt: DateTimeHelpers.UnixTimestampToDateTime(34567), expiresOn: DateTimeHelpers.UnixTimestampToDateTime(12345), extendedExpiresOn: DateTimeHelpers.UnixTimestampToDateTime(23456)); item.Environment = item.Environment + $"_{keyPrefix}{i}"; // ensure we get unique cache keys accessor.SaveAccessToken(item); } for (int i = 1; i <= numRefreshTokens; i++) { var item = CreateRefreshTokenItem(); item.Environment = item.Environment + $"_{keyPrefix}{i}"; // ensure we get unique cache keys accessor.SaveRefreshToken(item); } // Create an FRT var frt = CreateRefreshTokenItem(true); frt.FamilyId = "1"; accessor.SaveRefreshToken(frt); for (int i = 1; i <= numIdTokens; i++) { var item = CreateIdTokenItem(); item.Environment = item.Environment + $"_{keyPrefix}{i}"; // ensure we get unique cache keys accessor.SaveIdToken(item); } for (int i = 1; i <= numAccounts; i++) { var item = CreateAccountItem(); item.Environment = item.Environment + $"_{keyPrefix}{i}"; // ensure we get unique cache keys accessor.SaveAccount(item); } accessor.SaveAppMetadata(new MsalAppMetadataCacheItem(TestConstants.ClientId, "env_1", "1")); accessor.SaveAppMetadata(new MsalAppMetadataCacheItem(TestConstants.ClientId, "env_2", "")); accessor.SaveAppMetadata(new MsalAppMetadataCacheItem(TestConstants.ClientId2, "env_1", "another_family")); return(accessor); }