Example #1
0
        public async Task ObservableItemSourceCollectionItemsSourceChangedReset()
        {
            tlog.Debug(tag, $"ObservableItemSourceCollectionItemsSourceChanged START");

            TaskCompletionSource <bool>         tcs       = new TaskCompletionSource <bool>(false);
            NotifyCollectionChangedEventHandler onChanged = (s, e) => { tcs.TrySetResult(true); };

            var para          = new TestModel();
            var cView         = new CollectionView(para);
            var testingTarget = new ObservableItemSource(cView.ItemsSource, cView);

            testingTarget.CollectionItemsSourceChanged += onChanged;

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ObservableItemSource>(testingTarget, "should be an instance of testing target class!");

            para[0] = "test";
            para.Clear();

            var result = await tcs.Task;

            Assert.IsTrue(result, "Change event should be invoked");
            Assert.AreEqual(testingTarget.Count, 0, "should be equal.");

            tlog.Debug(tag, $"ObservableItemSourceCollectionItemsSourceChanged END (OK)");
        }