Skip to content

Commit

Permalink
Removing unnecessary comments in Unit Test for URF Api's to support p…
Browse files Browse the repository at this point in the history
…agination.
  • Loading branch information
lelong37 committed Feb 9, 2018
1 parent 3880086 commit 3114ddc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions URF.Core.EF.Tests/RepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public async Task Fluent_Api_Should_Support_Paging()
{
var repository = new Repository<Product>(_fixture.Context);

// Arrange
var expected = new[]
{
new Product {ProductId = 67, ProductName = "Laughing Lumberjack Lager", CategoryId = 1, UnitPrice = 14.00m, Discontinued = false},
Expand All @@ -276,15 +277,17 @@ public async Task Fluent_Api_Should_Support_Paging()
new Product {ProductId = 4, ProductName = "Chef Anton's Cajun Seasoning", CategoryId = 2, UnitPrice = 22.00m, Discontinued = false}
};

const int page = 2; // current page
const int pageSize = 10; // page size
const int page = 2;
const int pageSize = 10;

var count = await repository // total count is needed for paging
// Act
var count = await repository
.Query()
.Where(p => p.CategoryId == 1 || p.CategoryId == 2)
.CountAsync();

var products = await repository // paging w/ filter, deep loading, sorting
// Act
var products = await repository
.Query()
.Where(p => p.CategoryId == 1 || p.CategoryId == 2)
.Include(p => p.Category)
Expand All @@ -297,6 +300,7 @@ public async Task Fluent_Api_Should_Support_Paging()

const int assertionCount = 24;

// Assert
Action<Product>[] collectionAssertions = {
p => Assert.Equal(expected[0].ProductId, p.ProductId),
p => Assert.Equal(expected[1].ProductId, p.ProductId),
Expand All @@ -310,13 +314,16 @@ public async Task Fluent_Api_Should_Support_Paging()
p => Assert.Equal(expected[9].ProductId, p.ProductId)
};

// Assert
Assert.NotEmpty(enumerable);
Assert.Equal(assertionCount, count);
Assert.Equal(pageSize, enumerable.Length);
Assert.Collection(enumerable, collectionAssertions);

// Act
var paginated = new Page<Product>(count, enumerable);

// Assert
Assert.Equal(assertionCount, paginated.Count);
Assert.Collection(paginated.Value, collectionAssertions);
}
Expand Down

0 comments on commit 3114ddc

Please sign in to comment.