我需要在此源代码上编写一些单元测试。
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);
}
}
我还有1个关于单元测试的问题:模拟和存根有什么区别?