コード例 #1
0
        public void MobileServiceCollectionCanRemoveAtAndNotifies()
        {
            // 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>()
            {
                "Count", "Item[]"
            };
            List <NotifyCollectionChangedAction> actions         = new List <NotifyCollectionChangedAction>();
            List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>()
            {
                NotifyCollectionChangedAction.Remove
            };

            Book book = new Book();

            collection.Add(book);

            ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName);
            collection.CollectionChanged += (s, e) => actions.Add(e.Action);
            collection.RemoveAt(0);

            Assert.AreEqual(0, collection.Count);
            Assert.IsTrue(properties.SequenceEqual(expectedProperties));
            Assert.IsTrue(actions.SequenceEqual(expectedActions));
        }
コード例 #2
0
        public void MobileServiceCollectionCanRemoveAtAndNotifies()
        {
            // 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>() { "Count", "Item[]" };
            List<NotifyCollectionChangedAction> actions = new List<NotifyCollectionChangedAction>();
            List<NotifyCollectionChangedAction> expectedActions = new List<NotifyCollectionChangedAction>() { NotifyCollectionChangedAction.Remove };

            Book book = new Book();
            collection.Add(book);

            ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName);
            collection.CollectionChanged += (s, e) => actions.Add(e.Action);
            collection.RemoveAt(0);

            Assert.AreEqual(0, collection.Count);
            Assert.IsTrue(properties.SequenceEqual(expectedProperties));
            Assert.IsTrue(actions.SequenceEqual(expectedActions));
        }