Пример #1
0
        public MessageBirdTests()
        {
            var clientFactory = A.Fake <IHttpClientFactory>();

            A.CallTo(() => clientFactory.CreateClient(A <string> ._))
            .ReturnsLazily(() => new HttpClient());

            sut = new MessageBirdClient(clientFactory, Options.Create(new MessageBirdOptions
            {
                PhoneNumber  = Environment.GetEnvironmentVariable("MESSAGEBIRD_PHONENUMBER") !,
                PhoneNumbers = null,
                AccessKey    = Environment.GetEnvironmentVariable("MESSAGEBIRD_KEY") !
            }));
Пример #2
0
        public MessageBirdTests()
        {
            var clientFactory = A.Fake <IHttpClientFactory>();

            A.CallTo(() => clientFactory.CreateClient(A <string> ._))
            .ReturnsLazily(() => new HttpClient());

            sut = new MessageBirdClient(clientFactory, Options.Create(new MessageBirdOptions
            {
                PhoneNumber  = TestHelpers.Configuration.GetValue <string>("messageBird:phoneNumber"),
                PhoneNumbers = null,
                AccessKey    = TestHelpers.Configuration.GetValue <string>("messageBird:accessKey")
            }));
        }
Пример #3
0
        public IMessageBirdClient GetServer(string accessKey, long phoneNumber, Dictionary <string, string>?phoneNumbers)
        {
            var cacheKey = $"MessageBirdSmsSender_{accessKey}_{phoneNumber}";

            var found = GetOrCreate(cacheKey, () =>
            {
                var options = Options.Create(new MessageBirdOptions
                {
                    AccessKey    = accessKey,
                    PhoneNumber  = phoneNumber.ToString(CultureInfo.InvariantCulture),
                    PhoneNumbers = phoneNumbers
                });

                var sender = new MessageBirdClient(httpClientFactory, options);

                return(sender);
            });

            return(found);
        }