public void AddEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name       = "Added City",
                StateName  = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType <City>().First();

            cities.Remove(removedCity);

            // A new city should not be added to the collection
            City addedCity = new City
            {
                Name       = "Added City 2",
                StateName  = "ST",
                CountyName = "County"
            };

            this.AssertCollectionChanged(
                () => cities.Add(addedCity),
                pagedCollection,
                (NotifyCollectionChangedEventArgs)null,
                "when adding a new city.");

            // A restored city should be re-added to the collection
            this.AssertCollectionChanged(
                () => cities.Add(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, removedCity, pagedCollection.Count - 1),
                "when re-adding a removed city.");
        }
        public void RemoveEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name       = "Added City",
                StateName  = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType <City>().First();

            this.AssertCollectionChanged(
                () => cities.Remove(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedCity, 0),
                "when removing a city.");
        }
        public void AddEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name = "Added City",
                StateName = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType<City>().First();
            cities.Remove(removedCity);

            // A new city should not be added to the collection
            City addedCity = new City
            {
                Name = "Added City 2",
                StateName = "ST",
                CountyName = "County"
            };

            this.AssertCollectionChanged(
                () => cities.Add(addedCity),
                pagedCollection,
                (NotifyCollectionChangedEventArgs)null,
                "when adding a new city.");

            // A restored city should be re-added to the collection
            this.AssertCollectionChanged(
                () => cities.Add(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, removedCity, pagedCollection.Count - 1),
                "when re-adding a removed city.");
        }
        public void RemoveEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name = "Added City",
                StateName = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType<City>().First();
            this.AssertCollectionChanged(
                () => cities.Remove(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedCity, 0),
                "when removing a city.");
        }