コード例 #1
0
        public void ThenTheResultIsAsExpected()
        {
            var query = new AssetQuery {
                Owner = "user1", TeamAsset = true
            };
            var pageInfo = new PageInfo(
                2,
                2,
                new OrderBy(AssetRepository.CREATED_BY_COLUMN, Order.DESCENDING));
            var actual = _sut.PagedQuery(pageInfo, query);

            // Simulate the paging on the in-memory collection.
            var expected = _assets
                           .Where(x => x.Owner == "user1" && x.TeamAsset)
                           .OrderByDescending(x => x.CreatedBy)
                           .Skip(2)
                           .Take(2)
                           .ToList();

            Assert.AreEqual(pageInfo, actual.PageInfo);
            Assert.AreEqual(4, actual.TotalCount);
            Assert.AreEqual(2, actual.Result.Count());
            foreach (var expectedDto in expected)
            {
                var actualDto = actual.Result.Single(x => x.Id == expectedDto.Id);
                Assert.AreEqual(expectedDto, actualDto);
            }
        }