public async Task Read_With_NullableInt_LessThanPredicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product2() { Stock = 10 }); await dataContext.Create(new Product2() { Stock = 10 }); await dataContext.Create(new Product2() { Stock = 11 }); await dataContext.Create(new Product2() { Stock = 12 }); // Act IEnumerable <Product2> products = await dataContext.ReadList <Product2>(LessThan <Product2>(x => x.Stock, 11)); // Assert Assert.AreEqual(2, products.Count()); Assert.That(new[] { 10 }, Is.EquivalentTo(products.Select(x => x.Stock).Distinct())); }
public async Task Read_With_String_In_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product() { Name = "Spanner" }); await dataContext.Create(new Product() { Name = "Hammer" }); await dataContext.Create(new Product() { Name = "Nail" }); // Act string[] productNames = new[] { "Hammer", "Nail" }; IEnumerable <Product> products = await dataContext.ReadList <Product>(In <Product>(x => x.Name, productNames)); // Assert Assert.That(productNames, Is.EquivalentTo(products.Select(x => x.Name))); }
public async Task Read_With_String_NotIn_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product() { Name = "Spanner" }); await dataContext.Create(new Product() { Name = "Hammer" }); await dataContext.Create(new Product() { Name = "Nail" }); // Act string[] productNames = new[] { "Hammer", "Nail" }; IEnumerable <Product> products = await dataContext.ReadList <Product>(NotIn <Product>(x => x.Name, productNames)); // Assert Assert.AreEqual(1, products.Count()); Assert.AreEqual("Spanner", products.ElementAt(0).Name); }
public async Task Read_By_Id_With_Soft_Delete_And_Sequential_Partition_Key(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); SoftDeletePartition1 sd1 = await dataContext.Create(new SoftDeletePartition1() { Value = "Test 1" }); SoftDeletePartition2 sd2 = await dataContext.Create(new SoftDeletePartition2() { Value = "Test 2" }); // Act SoftDeletePartition1 one = await dataContext.Read <SoftDeletePartition1>(sd1.Id); SoftDeletePartition2 two = await dataContext.Read <SoftDeletePartition2>(sd2.Id); // Assert Assert.NotNull(one); Assert.AreEqual(sd1.Id, one.Id); Assert.NotNull(two); Assert.AreEqual(sd2.Id, two.Id); }
public async Task Read_With_Sequential_Partition_Key(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new ProductPartition1() { Name = "Test", IsForSale = true }); await dataContext.Create(new ProductPartition1() { Name = "Test 2", IsForSale = true }); await dataContext.Create(new ProductPartition2() { Name = "Test", IsForSale = true }); await dataContext.Create(new ProductPartition2() { Name = "Test 2", IsForSale = true }); // Act IEnumerable <ProductPartition2> twos = await dataContext.ReadList <ProductPartition2>(new { IsForSale = true }); // Assert Assert.AreEqual(2, twos.Count()); Assert.That(twos.All(x => x.Id >= 100001)); }
public async Task Delete_List_Non_Existing_Conditions(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create <City>(new City() { CityCode = "BAS", CityName = "Basingstoke", Area = "Hampshire" }); await dataContext.Create <City>(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create <City>(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); await dataContext.Create <City>(new City() { CityCode = "HAV", CityName = "Havant", Area = "Hampshire" }); // Act / Assert Assert.ThrowsAsync <ArgumentException>(async() => { await dataContext.DeleteList <City>(new { Code = "BAS" }); }); Assert.ThrowsAsync <ArgumentException>(async() => { await dataContext.DeleteList <City>(new { Name = "Portsmouth", Area = "Hampshire" }); }); }
public async Task Delete_List_Of_Entities(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create <City>(new City() { CityCode = "BAS", CityName = "Basingstoke", Area = "Hampshire" }); await dataContext.Create <City>(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create <City>(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); await dataContext.Create <City>(new City() { CityCode = "HAV", CityName = "Havant", Area = "Hampshire" }); // Act await dataContext.DeleteList <City>(new { Area = "Hampshire" }); // Assert Assert.AreEqual(0, (await dataContext.ReadList <City>(new { Area = "Hampshire" })).Count()); Assert.AreEqual(1, (await dataContext.ReadAll <City>()).Count()); }
public async Task Read_List_By_Where_Condition_Implied_In_And_Equal(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "CHI", CityName = "Chichester", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Act string[] cityCodes = new[] { "PUP", "BOU", "CHI" }; IEnumerable <City> cities = await dataContext.ReadList <City>(new { CityCode = cityCodes, Area = "West Sussex" }); // Assert Assert.That(new[] { "CHI" }, Is.EquivalentTo(cities.Select(x => x.CityCode))); }
public async Task Read_With_Predicates_Return_Null(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "CHI", CityName = "Chichester", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Act City city = await dataContext.Read <City>(Equal <City>(x => x.Area, "East Sussex")); // Assert Assert.IsNull(city); }
public async Task Read_With_Int_In_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product() { Stock = 10 }); await dataContext.Create(new Product() { Stock = 10 }); await dataContext.Create(new Product() { Stock = 11 }); await dataContext.Create(new Product() { Stock = 12 }); // Act int[] stock = new[] { 10, 12 }; IEnumerable <Product> products = await dataContext.ReadList <Product>(In <Product>(x => x.Stock, stock)); // Assert Assert.AreEqual(3, products.Count()); Assert.That(stock, Is.EquivalentTo(products.Select(x => x.Stock).Distinct())); }
public async Task Read_List_By_Where_Condition(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Act IEnumerable <City> cities = await dataContext.ReadList <City>(new { Area = "Hampshire" }); // Assert // NOTE: there is only one team in Hampshire Assert.AreEqual(2, cities.Count()); }
public async Task Read_With_Int_NotBetween_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product() { Stock = 5 }); await dataContext.Create(new Product() { Stock = 10 }); await dataContext.Create(new Product() { Stock = 15 }); await dataContext.Create(new Product() { Stock = 20 }); // Act IEnumerable <Product> products = await dataContext.ReadList <Product>(NotBetween <Product>(x => x.Stock, 11, 20)); // Assert Assert.AreEqual(2, products.Count()); Assert.That(new[] { 5, 10 }, Is.EquivalentTo(products.Select(x => x.Stock).Distinct())); }
public async Task Read_With_Int_GreaterThanOrEqual_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product() { Stock = 10 }); await dataContext.Create(new Product() { Stock = 10 }); await dataContext.Create(new Product() { Stock = 11 }); await dataContext.Create(new Product() { Stock = 12 }); // Act IEnumerable <Product> products = await dataContext.ReadList <Product>(GreaterThanOrEqual <Product>(x => x.Stock, 11)); // Assert Assert.AreEqual(2, products.Count()); Assert.That(new[] { 11, 12 }, Is.EquivalentTo(products.Select(x => x.Stock))); }
public async Task Read_With_Int_GreaterThan_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product() { Stock = 10 }); await dataContext.Create(new Product() { Stock = 10 }); await dataContext.Create(new Product() { Stock = 11 }); await dataContext.Create(new Product() { Stock = 12 }); // Act IEnumerable <Product> products = await dataContext.ReadList <Product>(GreaterThan <Product>(x => x.Stock, 11)); // Assert Assert.AreEqual(1, products.Count()); Assert.AreEqual(12, products.ElementAt(0).Stock); }
public async Task Test_Updated_Records_Comitted(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); Product product1 = await dataContext.Create(new Product() { Name = "Product 1" }).ConfigureAwait(false); Product product2 = await dataContext.Create(new Product() { Name = "Product 1" }).ConfigureAwait(false); // Act dataContext.BeginTransaction(); product1.Name = "Product 3"; product2.Name = "Product 4"; await dataContext.Update <Product>(new { product1.Id, product1.Name }).ConfigureAwait(false); await dataContext.Update <Product>(new { product2.Id, product2.Name }).ConfigureAwait(false); dataContext.Commit(); // Assert Product updated1 = await dataContext.Read <Product>(product1.Id); Product updated2 = await dataContext.Read <Product>(product2.Id); Assert.AreEqual(product1.Name, updated1.Name); Assert.AreEqual(product2.Name, updated2.Name); }
public async Task Read_With_Predicates_Multiple_Results_Throws_Argument_Exception(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "CHI", CityName = "Chichester", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Act / Assert Assert.ThrowsAsync <ArgumentException>(async() => await dataContext.Read <City>(Equal <City>(x => x.Area, "Hampshire"))); }
public async Task Test_Updated_Records_Rolledback_Implicit(Type dataContextType) { // Arrange Product original1, original2, updated1, updated2; using (IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType)) { original1 = await dataContext.Create(new Product() { Name = "Product 1" }).ConfigureAwait(false); original2 = await dataContext.Create(new Product() { Name = "Product 2" }).ConfigureAwait(false); // Act dataContext.BeginTransaction(); updated1 = await dataContext.Update <Product>(new { original1.Id, Name = "Updated 1" }).ConfigureAwait(false); updated2 = await dataContext.Update <Product>(new { original2.Id, Name = "Updated 2" }).ConfigureAwait(false); } // Assert using IDataContext dataContext2 = DataContextTestHelper.SetupDataContext(dataContextType); Product read1 = await dataContext2.Read <Product>(original1.Id); Product read2 = await dataContext2.Read <Product>(original2.Id); Assert.AreEqual(original1.Name, read1.Name); Assert.AreEqual(original2.Name, read2.Name); Assert.AreNotEqual(updated1.Name, read1.Name); Assert.AreNotEqual(updated2.Name, read2.Name); }
public async Task Read_By_Id_With_Sequential_Partition_Key(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); ProductPartition1 p1 = await dataContext.Create(new ProductPartition1() { Name = "Test", IsForSale = true }); ProductPartition2 p2 = await dataContext.Create(new ProductPartition2() { Name = "Test", IsForSale = true }); // Act ProductPartition1 one = await dataContext.Read <ProductPartition1>(p1.Id); ProductPartition2 two = await dataContext.Read <ProductPartition2>(p2.Id); // Assert Assert.NotNull(one); Assert.AreEqual(p1.Id, one.Id); Assert.NotNull(two); Assert.AreEqual(p2.Id, two.Id); }
public async Task Delete_With_Sequential_Partition_Key(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new ProductPartition1() { Name = "Test", IsForSale = true }); await dataContext.Create(new ProductPartition1() { Name = "Test 2", IsForSale = true }); await dataContext.Create(new ProductPartition2() { Name = "Test", IsForSale = true }); await dataContext.Create(new ProductPartition2() { Name = "Test 2", IsForSale = true }); // Act await dataContext.DeleteList <ProductPartition2>(new { IsForSale = true }); // Assert Assert.IsFalse((await dataContext.ReadAll <ProductPartition2>()).Any()); Assert.IsTrue((await dataContext.ReadAll <ProductPartition1>()).Any()); }
public async Task Read_With_String_EndsWith_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product() { Name = "Bosch Hammer I" }); await dataContext.Create(new Product() { Name = "Black and Decker Hammer" }); await dataContext.Create(new Product() { Name = "Hammer B&Q" }); await dataContext.Create(new Product() { Name = "Something Else" }); // Act IEnumerable <Product> products = await dataContext.ReadList <Product>(EndsWith <Product>(x => x.Name, "Hammer")); // Assert Assert.AreEqual(1, products.Count()); Assert.AreEqual("Black and Decker Hammer", products.ElementAt(0).Name); }
public async Task Update_Read_Only_Column(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); // a value must be provided for the read-only property when used with an in memory // data context, SQL based implementations will take the value from the columns // default value ReadOnly readOnly = await dataContext.Create <ReadOnly>(new ReadOnly() { Editable = "Hello", ReadOnlyProperty = "Default" }); // Act readOnly = await dataContext.Update <ReadOnly>(new { readOnly.SequentialId, Editable = "Goodbye", ReadOnlyProperty = "Yesterday" }); // Assert Assert.AreEqual("Goodbye", readOnly.Editable); Assert.AreEqual("Default", readOnly.ReadOnlyProperty); }
public void TearDown() { if (TestContext.CurrentContext.Test.Arguments.Length > 0) { DataContextTestHelper.DeleteDataContext((Type)TestContext.CurrentContext.Test.Arguments[0]); } }
public async Task Read_With_NullableInt_NotIn_Predicate(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new Product2() { Stock = 10 }); await dataContext.Create(new Product2() { Stock = 10 }); await dataContext.Create(new Product2() { Stock = 11 }); await dataContext.Create(new Product2() { Stock = 12 }); // Act int[] stock = new[] { 10, 12 }; IEnumerable <Product2> products = await dataContext.ReadList <Product2>(NotIn <Product2>(x => x.Stock, stock)); // Assert Assert.AreEqual(1, products.Count()); Assert.AreEqual(11, products.ElementAt(0).Stock); }
public async Task Insert_With_Discriminator(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); // Act DiscriminatorContact contact = await dataContext.Create(new DiscriminatorContact() { Name = "Paul" }); DiscriminatorCompany company = await dataContext.Create(new DiscriminatorCompany() { Name = "The Beatles" }); // Assert Assert.Greater(contact.ContactId, 0); Assert.AreEqual(DiscriminatorType.Contact, contact.DiscriminatorType); Assert.AreEqual("Paul", contact.Name); Assert.Greater(company.CompanyId, 0); Assert.AreEqual(DiscriminatorType.Company, company.DiscriminatorType); Assert.AreEqual("The Beatles", company.Name); }
public async Task Insert_With_Sequential_Partition_Key_No_Existing_Rows(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); // Act ProductPartition1 partition1 = await dataContext.Create(new ProductPartition1() { Name = "1" }); ProductPartition2 partition2 = await dataContext.Create(new ProductPartition2() { Name = "100001" }); ProductPartition3 partition3 = await dataContext.Create(new ProductPartition3() { Name = "30000" }); // Assert Assert.AreEqual(1, partition1.Id); Assert.AreEqual(100001, partition2.Id); Assert.AreEqual(30000, partition3.Id); }
public async Task Insert_With_Composite_Key_Two_Assigned_And_One_Sequential(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); // Act AssignedPairAndSequential oneOneOne = await dataContext.Create(new AssignedPairAndSequential() { FirstAssignedId = 1, SecondAssignedId = 1, Heading = "One" }); AssignedPairAndSequential oneOneTwo = await dataContext.Create(new AssignedPairAndSequential() { FirstAssignedId = 1, SecondAssignedId = 1, Heading = "Two" }); AssignedPairAndSequential oneTwoOne = await dataContext.Create(new AssignedPairAndSequential() { FirstAssignedId = 1, SecondAssignedId = 2, Heading = "One" }); // Assert Assert.AreEqual(1, oneOneOne.SequentialId); Assert.AreEqual(2, oneOneTwo.SequentialId); Assert.AreEqual(1, oneTwoOne.SequentialId); }
public async Task Read_Paged_With_Where_Dictionary(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "BAS", CityName = "Basingstoke", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "WIN", CityName = "Winchester", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "PTR", CityName = "Petersfield", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "CHI", CityName = "Chichester", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOG", CityName = "Bognor Regis", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Act PagedList <City> pagedList = await dataContext.ReadList <City>( new Dictionary <string, object>() { { "Area", "Hampshire" } }, null, 4, 1); // Assert Assert.AreEqual(4, pagedList.Rows.Count()); Assert.AreEqual(false, pagedList.HasPrevious); Assert.AreEqual(true, pagedList.HasNext); Assert.AreEqual(2, pagedList.TotalPages); Assert.AreEqual(5, pagedList.TotalRows); }
public async Task Read_Paged_Last_Page(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "BAS", CityName = "Basingstoke", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "WIN", CityName = "Winchester", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "PTR", CityName = "Petersfield", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "CHI", CityName = "Chichester", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOG", CityName = "Bognor Regis", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Arrange - read the first page to see how many pages there are int lastPage = (await dataContext.ReadList <City>(null, null, 3, 1)).TotalPages; // Act - read the last page PagedList <City> pagedList = await dataContext.ReadList <City>(null, null, 3, lastPage); // Assert Assert.AreEqual(pagedList.TotalRows - ((lastPage - 1) * 3), pagedList.Rows.Count()); Assert.AreEqual(true, pagedList.HasPrevious); Assert.AreEqual(false, pagedList.HasNext); Assert.AreEqual(lastPage, pagedList.TotalPages); }
public async Task Read_Paged_With_Where_Dictionary_And_OrderBy_Dictionary(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "BAS", CityName = "Basingstoke", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "WIN", CityName = "Winchester", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "PTR", CityName = "Petersfield", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "CHI", CityName = "Chichester", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOG", CityName = "Bognor Regis", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Act PagedList <City> pagedList = await dataContext.ReadList <City>( new Dictionary <string, object>() { { "Area", "Hampshire" } }, new Dictionary <string, SortOrder>() { { "CityName", SortOrder.Descending } }, 5, 1); // Assert string[] expectedOrder = { "Winchester", "Southampton", "Portsmouth", "Petersfield", "Basingstoke" }; Assert.IsTrue(pagedList.Rows.Select(x => x.CityName).SequenceEqual(expectedOrder)); }
public async Task Read_Paged_Neither_First_Or_Last_Page(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); await dataContext.Create(new City() { CityCode = "PUP", CityName = "Portsmouth", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "SOU", CityName = "Southampton", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "BAS", CityName = "Basingstoke", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "WIN", CityName = "Winchester", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "PTR", CityName = "Petersfield", Area = "Hampshire" }); await dataContext.Create(new City() { CityCode = "CHI", CityName = "Chichester", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOG", CityName = "Bognor Regis", Area = "West Sussex" }); await dataContext.Create(new City() { CityCode = "BOU", CityName = "Bournemouth", Area = "Dorset" }); // Act PagedList <City> pagedList = await dataContext.ReadList <City>(null, null, 2, 2); // Assert Assert.AreEqual(2, pagedList.Rows.Count()); Assert.AreEqual(true, pagedList.HasPrevious); Assert.AreEqual(true, pagedList.HasNext); Assert.AreEqual(4, pagedList.TotalPages); Assert.AreEqual(8, pagedList.TotalRows); }