public void MobileServiceCollectionCanCopyToAndNotNotifies() { // Get the Books table MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection <Book> collection = new MobileServiceCollection <Book>(query); List <string> properties = new List <string>(); List <string> expectedProperties = new List <string>() { }; List <NotifyCollectionChangedAction> actions = new List <NotifyCollectionChangedAction>(); List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>() { }; Book book = new Book(); collection.Add(book); Book[] books = new Book[1]; ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); collection.CopyTo(books, 0); Assert.AreEqual(1, collection.Count); Assert.AreEqual(1, books.Count()); Assert.AreEqual(collection[0], books[0]); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
public void MobileServiceCollectionCanCopyToAndNotNotifies() { // Get the Books table MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection<Book, Book> collection = new MobileServiceCollection<Book, Book>(query); List<string> properties = new List<string>(); List<string> expectedProperties = new List<string>() { }; List<NotifyCollectionChangedAction> actions = new List<NotifyCollectionChangedAction>(); List<NotifyCollectionChangedAction> expectedActions = new List<NotifyCollectionChangedAction>() { }; Book book = new Book(); collection.Add(book); Book[] books = new Book[1]; ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); collection.CopyTo(books, 0); Assert.AreEqual(1, collection.Count); Assert.AreEqual(1, books.Count()); Assert.AreEqual(collection[0], books[0]); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }