예제 #1
0
        public async Task NoRefreshThrottleAllowsCalls()
        {
            var currentThrottle = TrelloConfiguration.RefreshThrottle;

            try
            {
                MockHost.MockJson();
                MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>())
                .Returns(new SynchronizedData());

                TrelloConfiguration.RefreshThrottle = TimeSpan.Zero;

                var target = new SynchronizedObject();

                await target.Synchronize(false, CancellationToken.None);

                await target.Synchronize(false, CancellationToken.None);

                target.RetrievalCount.Should().Be(2);
            }
            finally
            {
                TrelloConfiguration.RefreshThrottle = currentThrottle;
            }
        }
예제 #2
0
        public void MergeRaisesSynchronizedEvent()
        {
            MockHost.MockJson();
            MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>())
            .Returns(new SynchronizedData());

            TrelloConfiguration.RefreshThrottle = TimeSpan.FromDays(1);

            var counter = 0;

            var target = new SynchronizedObject
            {
                NewData = new SynchronizedData {
                    Test = "one"
                }
            };

            target.PublicSynchronized += properties => counter++;

            target.Merge(new SynchronizedData {
                Test = "two"
            });

            counter.Should().Be(1);
            target.Data.Test.Should().Be("two");
        }
예제 #3
0
        public async Task ForcedRefreshOverridesThrottle()
        {
            var currentThrottle = TrelloConfiguration.RefreshThrottle;

            try
            {
                MockHost.MockJson();
                MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>())
                .Returns(new SynchronizedData());

                TrelloConfiguration.RefreshThrottle = TimeSpan.FromDays(1);

                var target = new SynchronizedObject();

                await target.Synchronize(true, CancellationToken.None);

                await target.Synchronize(true, CancellationToken.None);

                target.RetrievalCount.Should().Be(2);
            }
            finally
            {
                TrelloConfiguration.RefreshThrottle = currentThrottle;
            }
        }
예제 #4
0
        public async Task SynchronizeRaisesSynchronizedEvent()
        {
            var currentThrottle = TrelloConfiguration.RefreshThrottle;

            try
            {
                MockHost.MockJson();
                MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>())
                .Returns(new SynchronizedData());

                TrelloConfiguration.RefreshThrottle = TimeSpan.FromDays(1);

                var counter = 0;

                var target = new SynchronizedObject
                {
                    NewData = new SynchronizedData {
                        Test = "one"
                    }
                };
                target.PublicSynchronized += properties => counter++;

                await target.Synchronize(false, CancellationToken.None);

                counter.Should().Be(1);
            }
            finally
            {
                TrelloConfiguration.RefreshThrottle = currentThrottle;
            }
        }
예제 #5
0
        public void GetValueDoesNotRetrieve()
        {
            MockHost.MockJson();
            MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>())
            .Returns(new SynchronizedData());

            var target = new SynchronizedObject();

            var value = target.GetValue <string>(nameof(SynchronizedData.Test));

            value.Should().Be("default");
            target.RetrievalCount.Should().Be(0);
        }
예제 #6
0
        public async Task UnsupportedUpdateSkipsSubmission()
        {
            MockHost.MockJson();
            MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>())
            .Returns(new SynchronizedData());

            var target = new SynchronizedObject {
                SupportsUpdates = false
            };

            await target.Synchronize(false, CancellationToken.None);

            target.SubmissionCount.Should().Be(0);
        }
예제 #7
0
        public async Task SettingDataMergesRequests()
        {
            MockHost.MockJson();
            MockHost.JsonFactory.Setup(f => f.Create <SynchronizedData>())
            .Returns(new SynchronizedData());

            TrelloConfiguration.ChangeSubmissionTime = TimeSpan.FromMilliseconds(100);

            var target = new SynchronizedObject();

            await target.SetValue(nameof(SynchronizedData.Test), "one", CancellationToken.None);

            await target.SetValue(nameof(SynchronizedData.Test), "two", CancellationToken.None);

            await Task.Delay(150);

            target.SubmissionCount.Should().Be(1);
        }