public void CanCreateFromIObservableVector()
        {
            RunOnUIThread.Execute(() =>
            {
                var data       = new WinRTObservableVector(Enumerable.Range(0, 100).Select(i => string.Format("Item #{0}", i)));
                var dataSource = new ItemsSourceView(data);
                var recorder   = new CollectionChangeRecorder(dataSource);
                Verify.AreEqual(100, dataSource.Count);
                Verify.AreEqual("Item #4", (string)dataSource.GetAt(4));
                Verify.IsFalse(dataSource.HasKeyIndexMapping);

                data.Insert(4, "Inserted Item");
                data.RemoveAt(7);
                data[15] = "Replaced Item";
                data.Clear();

                VerifyRecordedCollectionChanges(
                    expected: new NotifyCollectionChangedEventArgs[]
                {
                    CollectionChangeEventArgsConverters.CreateNotifyArgs(NotifyCollectionChangedAction.Add, -1, 0, 4, 1),
                    CollectionChangeEventArgsConverters.CreateNotifyArgs(NotifyCollectionChangedAction.Remove, 7, 1, -1, 0),
                    CollectionChangeEventArgsConverters.CreateNotifyArgs(NotifyCollectionChangedAction.Replace, 15, 1, 15, 1),
                    CollectionChangeEventArgsConverters.CreateNotifyArgs(NotifyCollectionChangedAction.Reset, -1, 0, -1, 0),
                },
                    actual: recorder.RecordedArgs);
            });
        }
 public void CanCreateFromIBindableIterable()
 {
     RunOnUIThread.Execute(() =>
     {
         var dataSource = new ItemsSourceView(Enumerable.Range(0, 100));
         Verify.AreEqual(100, dataSource.Count);
         Verify.AreEqual(4, dataSource.GetAt(4));
     });
 }
Exemple #3
0
        public void VerifyReadOnlyListCompatibility()
        {
            RunOnUIThread.Execute(() =>
            {
                var collection = new ReadOnlyNotifyPropertyChangedCollection <object>();
                var firstItem  = "something1";

                collection.Data = new ObservableCollection <object>();

                collection.Data.Add(firstItem);
                collection.Data.Add("something2");
                collection.Data.Add("something3");

                var itemsSourceView = new ItemsSourceView(collection);
                Verify.AreEqual(3, itemsSourceView.Count);

                collection.Data.Add("something4");
                Verify.AreEqual(4, itemsSourceView.Count);

                Verify.AreEqual(firstItem, itemsSourceView.GetAt(0));
                Verify.AreEqual(0, itemsSourceView.IndexOf(firstItem));
            });
        }