public void ProcessPushNotificationThrowsArgumentExceptions()
        {
            var mockResponse = new Mock <Response>();
            var mockClient   = GetMockConfigurationClient();

            IConfigurationRefresher refresher = null;

            var config = new ConfigurationBuilder()
                         .AddAzureAppConfiguration(options =>
            {
                options.Client = mockClient.Object;
                options.Select("*");
                options.ConfigureRefresh(refreshOptions =>
                {
                    refreshOptions.Register("TestKey1", "label")
                    .SetCacheExpiration(TimeSpan.FromDays(30));
                });
                refresher = options.GetRefresher();
            })
                         .Build();

            foreach (PushNotification invalidPushNotification in _invalidPushNotificationList)
            {
                Action action = () => refresher.ProcessPushNotification(invalidPushNotification);
                Assert.Throws <ArgumentException>(action);
            }

            PushNotification nullPushNotification = null;

            Action nullAction = () => refresher.ProcessPushNotification(nullPushNotification);

            Assert.Throws <ArgumentNullException>(nullAction);
        }
        public void RefreshAsyncUpdatesConfig()
        {
            // Arrange
            var mockResponse = new Mock <Response>();
            var mockClient   = GetMockConfigurationClient();

            IConfigurationRefresher refresher = null;

            var config = new ConfigurationBuilder()
                         .AddAzureAppConfiguration(options =>
            {
                options.Client = mockClient.Object;
                options.Select("*");
                options.ConfigureRefresh(refreshOptions =>
                {
                    refreshOptions.Register("TestKey1", "label")
                    .SetCacheExpiration(TimeSpan.FromDays(30));
                });
                refresher = options.GetRefresher();
            })
                         .Build();


            Assert.Equal("TestValue1", config["TestKey1"]);
            FirstKeyValue.Value = "newValue1";

            refresher.ProcessPushNotification(_pushNotificationList.First(), TimeSpan.FromSeconds(0));
            refresher.RefreshAsync().Wait();

            Assert.Equal("newValue1", config["TestKey1"]);
        }
        public void SyncTokenUpdatesCorrectNumberOfTimes()
        {
            // Arrange
            var mockResponse = new Mock <Response>();
            var mockClient   = GetMockConfigurationClient();

            IConfigurationRefresher refresher = null;

            var config = new ConfigurationBuilder()
                         .AddAzureAppConfiguration(options =>
            {
                options.Client = mockClient.Object;
                options.Select("*");
                options.ConfigureRefresh(refreshOptions =>
                {
                    refreshOptions.Register("TestKey1", "label")
                    .SetCacheExpiration(TimeSpan.FromDays(30));
                });
                refresher = options.GetRefresher();
            })
                         .Build();

            foreach (PushNotification pushNotification in _pushNotificationList)
            {
                refresher.ProcessPushNotification(pushNotification, TimeSpan.FromSeconds(0));
                refresher.RefreshAsync().Wait();
            }

            mockClient.Verify(c => c.GetConfigurationSettingAsync(It.IsAny <ConfigurationSetting>(), It.IsAny <bool>(), It.IsAny <CancellationToken>()), Times.Exactly(_pushNotificationList.Count));
            mockClient.Verify(c => c.UpdateSyncToken(It.IsAny <string>()), Times.Exactly(_pushNotificationList.Count));
        }