Skip to content

Commit ae54133

Browse files
committed
Merge pull request AuthorizeNet#104 from zalak1612/master
add test case for pagination issue
2 parents c4aa94f + 7c11154 commit ae54133

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

AuthorizeNETtest/Api/Controllers/Test/ArbSubscriptionTest.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,63 @@ public void GetSubscriptionSearchCardExpiringThisMonthFixTest()
291291
Assert.IsNotNull(arbGetSubscriptionListResponse);
292292
}
293293

294+
private ARBGetSubscriptionListResponse GetSubscriptionListResponse(int limitNo, int offSetNo)
295+
{
296+
var getSubscriptionList = new ARBGetSubscriptionListRequest()
297+
{
298+
searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive,
299+
paging = new Paging()
300+
{
301+
limit = limitNo,
302+
offset = offSetNo
303+
},
304+
305+
};
306+
307+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
308+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;
309+
var arbGetSubscriptionListController = new ARBGetSubscriptionListController(getSubscriptionList);
310+
var arbGetSubscriptionListResponse = arbGetSubscriptionListController.ExecuteWithApiResponse();
311+
return arbGetSubscriptionListResponse;
312+
313+
}
314+
/// <summary>
315+
/// @Zalak
316+
/// Test case for Pagination issue reported in Jira:
317+
/// C# - ARBSubscriptionList SearchType of "cardExpiringThisMonth" doesn't work
318+
/// </summary>
319+
[Test]
320+
public void ARBGetSubscriptionListCheckPagination()
321+
{
294322

323+
var arbGetSubscriptionListResponse = GetSubscriptionListResponse(1, 1);
324+
ARBGetSubscriptionListResponse response = null;
325+
int limitNo = 3;
326+
int offSetNo = 2;
327+
328+
if (arbGetSubscriptionListResponse != null)
329+
{
330+
int subcriptionNumber = arbGetSubscriptionListResponse.totalNumInResultSet;
331+
int expectedSubscriptionNo = 0;
332+
int nPages = subcriptionNumber/limitNo;
333+
int subscriptionDetailsOnLastPage = subcriptionNumber%limitNo;
334+
if (offSetNo <= nPages)
335+
expectedSubscriptionNo = limitNo;
336+
else if (offSetNo > (nPages + 1))
337+
expectedSubscriptionNo = 0;
338+
else
339+
{
340+
expectedSubscriptionNo = subscriptionDetailsOnLastPage;
341+
}
342+
response = GetSubscriptionListResponse(limitNo, offSetNo);
343+
Assert.AreEqual(expectedSubscriptionNo, response.subscriptionDetails.Count());
344+
}
345+
else
346+
{
347+
Assert.Null(arbGetSubscriptionListResponse);
348+
}
349+
350+
}
295351

296352

297353
private ARBCreateSubscriptionController CreateSubscriptionRequestTest(ARBSubscriptionType subscriptionRequestParameter)

0 commit comments

Comments
 (0)