public async Task ObservableItemSourceCollectionItemsSourceChangedRemove() { 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.Add("test"); para.Remove("test"); var result = await tcs.Task; Assert.IsTrue(result, "Change event should be invoked"); Assert.AreEqual(testingTarget.Count, 20, "should be equal."); tlog.Debug(tag, $"ObservableItemSourceCollectionItemsSourceChanged END (OK)"); }
public async Task ObservableGroupedSourceCollectionItemsSourceChangedAdd() { tlog.Debug(tag, $"ObservableItemSourceCollectionItemsSourceChanged START"); TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(false); NotifyCollectionChangedEventHandler onChanged = (s, e) => { tcs.TrySetResult(true); }; var model = new TestModel(); var cView = new CollectionView(model); var testingTarget = new ObservableGroupedSource(cView, cView); model.CollectionChanged += onChanged; Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <ObservableGroupedSource>(testingTarget, "should be an instance of testing target class!"); model.Add("test"); testingTarget.NotifyItemInserted(testingTarget, model.Count - 1); var result = await tcs.Task; Assert.IsTrue(result, "Change event should be invoked"); tlog.Debug(tag, "Count : " + testingTarget.Count); tlog.Debug(tag, $"ObservableItemSourceCollectionItemsSourceChanged END (OK)"); }
public ActionResult Add() { TestModel tm = new TestModel(); tm.Add(this.Request.Params["Name"], Convert.ToInt32(this.Request.Params["Num"])); return(null); }
public async Task MarshalingObservableCollectionCollectionChangedAdd() { tlog.Debug(tag, $"MarshalingObservableCollectionCollectionChangedAdd START"); TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(false); NotifyCollectionChangedEventHandler onChanged = (s, e) => { tcs.TrySetResult(true); }; var para = new TestModel(); var testingTarget = new MarshalingObservableCollection(para); testingTarget.CollectionChanged += onChanged; Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <MarshalingObservableCollection>(testingTarget, "should be an instance of testing target class!"); para.Add("Test"); var result = await tcs.Task; Assert.IsTrue(result, "Change event should be invoked"); Assert.AreEqual(testingTarget.Count, 21, "should be equal."); tlog.Debug(tag, $"MarshalingObservableCollectionCollectionChangedAdd END (OK)"); }
public IActionResult Post([FromBody] TestData item) { _model.Add(item); return(Ok()); }