0

I need to write some unit tests on this source code.

public class PagedCollection<T> : ReadOnlyCollection<T>, IPagedCollection<T>
{
    public int CurrentPage { get; }
    public int TotalPages { get; }
    public int PageSize { get; }
    public int TotalCount { get; }
    public bool HasPrevious => CurrentPage > 1;
    public bool HasNext => CurrentPage < TotalPages;

    public PagedCollection(ICollection<T> items, int count, int pageNumber, int pageSize) : base(items.ToList())
    {
        EnsureArg.IsGte(count, 0, nameof(count));
        EnsureArg.IsGt(pageNumber, 0, nameof(pageNumber));
        EnsureArg.IsGt(pageSize, 0, nameof(pageSize));

        TotalCount = count;
        CurrentPage = pageNumber;
        PageSize = pageSize;
        TotalPages = (int)Math.Ceiling(count / (double)pageSize);
    }
}

And I have 1 more question about unit testing: what is difference between mock and stub?

Jakub
  • 1
  • 2
    Welcome to Stack Overflow! We expect questions here to relate to _specific_ programming problems. Just telling what you need is likely to be considered as "too broad" or "unclear what you are asking". We expect everyone to do some own research first. Tell us what you've tried, and where you are stuck. See also: [How to Ask](https://stackoverflow.com/questions/how-to-ask). I would recommend to make yourself familiar with TDD first. And please ask only one question at a time. The other one has aready an answer here: https://stackoverflow.com/q/3459287/2311167 – Adrian W Jul 10 '18 at 18:18
  • 1
    What was your **first** question again? – jingx Jul 10 '18 at 19:23

0 Answers0