Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit c533d30

Browse files
committed
Add failing test for exceptions in SequentialListSource.
1 parent 59b6c01 commit c533d30

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

test/GitHub.App.UnitTests/Collections/SequentialListSourceTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Threading.Tasks;
45
using GitHub.Collections;
@@ -34,6 +35,17 @@ public async Task GetPage_Should_Load_Pages()
3435
Assert.That(target.PagesLoaded, Is.EqualTo(new[] { 0, 1, 2, 3 }));
3536
}
3637

38+
[Test]
39+
public void GetPage_Should_Stop_Loading_Pages_When_LoadPage_Throws()
40+
{
41+
var target = new TestSource(2);
42+
43+
Assert.That(target.PagesLoaded, Is.Empty);
44+
45+
Assert.ThrowsAsync<AggregateException>(() => target.GetPage(3));
46+
Assert.That(target.PagesLoaded, Is.EqualTo(new[] { 0, 1 }));
47+
}
48+
3749
class TestSource : SequentialListSource<string, string>
3850
{
3951
const int PageCount = 10;

test/GitHub.App.UnitTests/GitHub.App.UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<Compile Include="..\Helpers\TestSharedCache.cs" />
158158
<Compile Include="Args.cs" />
159159
<Compile Include="Caches\ImageCacheTests.cs" />
160+
<Compile Include="Collections\SequentialListSourceTests.cs" />
160161
<Compile Include="Factories\ModelServiceFactoryTests.cs" />
161162
<Compile Include="Models\AccountModelTests.cs" />
162163
<Compile Include="Models\ModelServiceTests.cs" />

0 commit comments

Comments
 (0)