/// <summary> /// Create a <see cref="MockEntitySet"/> with cities loaded into it. Load those cities /// into the <paramref name="pagedCollection"/>. /// </summary> /// <param name="raiseCollectionChangedEvents">Whether or not the <see cref="MockEntitySet"/> should raise /// <see cref="INotifyCollectionChanged.CollectionChanged"/> events.</param> /// <param name="pagedCollection">The <see cref="PagedEntityCollection"/> to hook up to /// the loaded <see cref="MockEntitySet"/>. If <c>null</c>, it will be instantiated. /// The cities loaded into the <see cref="MockEntitySet"/> will also be loaded into /// the <paramref name="pagedCollection"/>.</param> /// <returns>The <see cref="MockEntitySet"/> with cities loaded into it.</returns> private MockEntitySet LoadCities(bool raiseCollectionChangedEvents, PagedEntityCollection pagedCollection) { // Get a mock entity set of cities MockEntitySet cities = new MockEntitySet(raiseCollectionChangedEvents); // Load a couple of cities into the set cities.Add(new City { Name = "First City", StateName = "ST", CountyName = "County" }); cities.Add(new City { Name = "Second City", StateName = "ST", CountyName = "County" }); // Create a paged collection for the entity set pagedCollection.BackingEntitySet = cities; // Process the cities as loaded entities pagedCollection.BeginLoad(); foreach (City city in cities) { pagedCollection.AddLoadedEntity(city); } pagedCollection.CompleteLoad(); return(cities); }
public void RepeatedEntitiesNoDuplicated() { PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); }); // This will load the cities into the collection the first time MockEntitySet cities = LoadCities(false, pagedCollection); // Now we'll load the cities into the collection a second time pagedCollection.BeginLoad(); foreach (City city in cities) { pagedCollection.AddLoadedEntity(city); } pagedCollection.CompleteLoad(); Assert.AreEqual(cities.Count, pagedCollection.Count, "The counts should still match"); }
/// <summary> /// Create a <see cref="MockEntitySet"/> with cities loaded into it. Load those cities /// into the <paramref name="pagedCollection"/>. /// </summary> /// <param name="raiseCollectionChangedEvents">Whether or not the <see cref="MockEntitySet"/> should raise /// <see cref="INotifyCollectionChanged.CollectionChanged"/> events.</param> /// <param name="pagedCollection">The <see cref="PagedEntityCollection"/> to hook up to /// the loaded <see cref="MockEntitySet"/>. If <c>null</c>, it will be instantiated. /// The cities loaded into the <see cref="MockEntitySet"/> will also be loaded into /// the <paramref name="pagedCollection"/>.</param> /// <returns>The <see cref="MockEntitySet"/> with cities loaded into it.</returns> private MockEntitySet LoadCities(bool raiseCollectionChangedEvents, PagedEntityCollection pagedCollection) { // Get a mock entity set of cities MockEntitySet cities = new MockEntitySet(raiseCollectionChangedEvents); // Load a couple of cities into the set cities.Add(new City { Name = "First City", StateName = "ST", CountyName = "County" }); cities.Add(new City { Name = "Second City", StateName = "ST", CountyName = "County" }); // Create a paged collection for the entity set pagedCollection.BackingEntitySet = cities; // Process the cities as loaded entities pagedCollection.BeginLoad(); foreach (City city in cities) { pagedCollection.AddLoadedEntity(city); } pagedCollection.CompleteLoad(); return cities; }
public void RepeatedEntitiesNoDuplicated() { PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; }); // This will load the cities into the collection the first time MockEntitySet cities = LoadCities(false, pagedCollection); // Now we'll load the cities into the collection a second time pagedCollection.BeginLoad(); foreach (City city in cities) { pagedCollection.AddLoadedEntity(city); } pagedCollection.CompleteLoad(); Assert.AreEqual(cities.Count, pagedCollection.Count, "The counts should still match"); }