public void Invoke() { var src = new TestCollection <int>(); for (var i = 0; i < 3; ++i) { src.Add(i); } var count = 0; src.CollectionChanged += (s, e) => ++ count; for (var i = 0; i < 3; ++i) { src.Add(i); } Assert.That(count, Is.EqualTo(3), "CollectionChanged"); Assert.That(src.Count(), Is.EqualTo(6), "Count"); }
public void Invoke_SynchronizationContext() { var src = new TestCollection <int>(); src.Set(new ContextInvoker(new SynchronizationContext(), true)); for (var i = 0; i < 10; ++i) { src.Add(i); } var count = 0; src.CollectionChanged += (s, e) => ++ count; for (var i = 0; i < 10; ++i) { src.Add(i); } Assert.That(count, Is.EqualTo(10), "CollectionChanged"); Assert.That(src.Count(), Is.EqualTo(20), "Count"); }