コード例 #1
0
        public void ShouldRaiseEventWhenItemIsAddedRemovedOrEdited()
        {
            var eventRaised = false;

            var collection = new TrulyObservableCollection <MockNotifiable>();

            collection.CollectionChanged += (s, e) => eventRaised = true;

            eventRaised = false;
            collection.Add(new MockNotifiable());
            Assert.That(eventRaised, Is.True);

            eventRaised = false;
            // The collection is supposed to raise the event if the property of one inner element is modified
            // This is the only added feature to the genuine ObservableCollection<>
            collection.First().Property = 100;
            Assert.That(eventRaised, Is.True);

            eventRaised = false;
            collection.RemoveAt(0);
            Assert.That(eventRaised, Is.True);
        }