예제 #1
0
    public async Task Enumerate_should_go_through_all_records()
    {
        var pager = new Pager(30);
        var list  = await pager.Enumerate(page => _client.GetResponse(page.Number, page.MaxSize));

        list.Should().BeEquivalentTo(_expectedList);
        await _client.Received(4).GetResponse(Arg.Any <int>(), Arg.Any <int>());
    }
예제 #2
0
    public PagerTests()
    {
        _expectedList = Enumerable.Range(0, 100);
        _client       = Substitute.For <IResponseClient>();

        _client.GetResponse(Arg.Any <int>(), Arg.Any <int>())
        .Returns(ci => _expectedList.Skip(((int)ci[0] - 1) * (int)ci[1]).Take((int)ci[1]).ToList().AsResponse());
    }