Skip to content

Commit 8f18324

Browse files
committed
test for cancel token, throw ex
1 parent f98242e commit 8f18324

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Paginator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ internal static int CalculateTotalPages(int totalItems, int perpage)
125125
{
126126
ans = totalItems / perpage;
127127
ans += (totalItems % perpage) > 0 ? 1 : 0;
128-
return ans;
129128
}
130129
return ans;
131130
}

tests/UnitTests.cs

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using NUnit.Framework;
44
using System;
55
using System.Threading.Tasks;
6+
using System.Threading;
67

78
namespace tests
89
{
@@ -105,6 +106,14 @@ public void AsyncPg_Invalid_PerPageParam_ThrowEx()
105106
{
106107
Assert.ThrowsAsync<ArgumentException>(() => Context.Cars.PaginateAsync(1, -1));
107108
}
109+
[Test]
110+
[Order(3)]
111+
public void AsyncPg_CancelledToken_Throw()
112+
{
113+
var src = new CancellationTokenSource();
114+
src.Cancel();
115+
Assert.ThrowsAsync<OperationCanceledException>(() => Context.Cars.PaginateAsync(1, 2, token: src.Token));
116+
}
108117
#endregion
109118
}
110119
}

0 commit comments

Comments
 (0)