Exemplo n.º 1
0
        public async Task Should_Not_Load_Duplicate_Pages()
        {
            var trigger = new Subject <Unit>();
            var target  = new TestSource(loadTrigger: trigger);

            var task1 = target.GetPage(1);
            var task2 = target.GetPage(1);

            Assert.That(target.PagesLoaded, Is.Empty);

            trigger.OnNext(Unit.Default);
            trigger.OnNext(Unit.Default);

            await task1;
            await task2;

            Assert.That(target.PagesLoaded, Is.EqualTo(new[] { 0, 1 }));
        }
Exemplo n.º 2
0
        public void GetPage_Should_Stop_Loading_Pages_When_LoadPage_Throws()
        {
            var target = new TestSource(2);

            Assert.That(target.PagesLoaded, Is.Empty);

            Assert.ThrowsAsync <AggregateException>(() => target.GetPage(3));
            Assert.That(target.PagesLoaded, Is.EqualTo(new[] { 0, 1 }));
        }
Exemplo n.º 3
0
        public void IsLoading_Should_Be_Set_To_False_When_LoadPage_Throws()
        {
            var target = new TestSource(2);

            Assert.That(target.PagesLoaded, Is.Empty);

            Assert.ThrowsAsync <AggregateException>(() => target.GetPage(3));
            Assert.That(target.IsLoading, Is.False);
        }
Exemplo n.º 4
0
        public async Task GetPage_Should_Load_Pages()
        {
            var target = new TestSource();

            Assert.That(target.PagesLoaded, Is.Empty);

            var count = await target.GetPage(3);

            Assert.That(target.PagesLoaded, Is.EqualTo(new[] { 0, 1, 2, 3 }));
        }