Ejemplo n.º 1
0
        public async Task Page_When_PageNumber_Is_Negative_Returns_PageNumberTh_Page_From_End(int pageSize, int pageNumber, int[] expectedIds)
        {
            var todoItems  = DbSetMock.Create(TodoItems(1, 2, 3, 4, 5, 6, 7, 8, 9)).Object;
            var repository = GetRepository();

            var result = await repository.PageAsync(todoItems, pageSize, pageNumber);

            Assert.Equal(TodoItems(expectedIds), result, new IdComparer <TodoItem>());
        }
Ejemplo n.º 2
0
        public async Task Page_When_PageNumber_Is_Zero_Pretends_PageNumber_Is_One()
        {
            var todoItems  = DbSetMock.Create(TodoItems(2, 3, 1)).Object;
            var repository = GetRepository();

            var result = await repository.PageAsync(todoItems, 1, 0);

            Assert.Equal(TodoItems(2), result, new IdComparer <TodoItem>());
        }
Ejemplo n.º 3
0
        public async Task Page_When_PageNumber_Of_PageSize_Does_Not_Exist_Return_Empty_Queryable()
        {
            var todoItems  = DbSetMock.Create(TodoItems(2, 3, 1)).Object;
            var repository = GetRepository();

            var result = await repository.PageAsync(todoItems, 2, 3);

            Assert.Empty(result);
        }
Ejemplo n.º 4
0
        public async Task Page_When_PageSize_Is_NonPositive_Does_Nothing(int pageSize)
        {
            var todoItems  = DbSetMock.Create(TodoItems(2, 3, 1)).Object;
            var repository = GetRepository();

            var result = await repository.PageAsync(todoItems, pageSize, 3);

            Assert.Equal(TodoItems(2, 3, 1), result, new IdComparer <TodoItem>());
        }
Ejemplo n.º 5
0
 public DefaultEntityRepository_Tests()
 {
     _todoItem = new TodoItem
     {
         Id          = 1,
         Description = Guid.NewGuid().ToString(),
         Ordinal     = 10
     };
     _jsonApiContextMock  = new Mock <IJsonApiContext>();
     _loggFactoryMock     = new Mock <ILoggerFactory>();
     _dbSetMock           = DbSetMock.Create <TodoItem>(new[] { _todoItem });
     _contextMock         = new Mock <DbContext>();
     _contextResolverMock = new Mock <IDbContextResolver>();
 }