using AutoFixture; using Bit.Core.NotificationHub; using Bit.Test.Common.AutoFixture; using Microsoft.Azure.NotificationHubs; using NSubstitute; using Xunit; namespace Bit.Core.Test.NotificationHub; public class NotificationHubProxyTests { private readonly IEnumerable _clients; public NotificationHubProxyTests() { _clients = new Fixture().WithAutoNSubstitutions().CreateMany(); } public static IEnumerable ClientMethods = [ [ (NotificationHubClientProxy c) => c.SendTemplateNotificationAsync(new Dictionary() { { "key", "value" } }, "tag"), (INotificationHubClient c) => c.SendTemplateNotificationAsync(Arg.Is>((a) => a.Keys.Count == 1 && a.ContainsKey("key") && a["key"] == "value"), "tag"), ], ]; [Theory] [MemberData(nameof(ClientMethods))] public async void CallsAllClients(Func proxyMethod, Func clientMethod) { var clients = _clients.ToArray(); var proxy = new NotificationHubClientProxy(clients); await proxyMethod(proxy); foreach (var client in clients) { await clientMethod(client.Received()); } } }