예제 #1
0
        public void Test_VstEventCollection_CollectionChanged_RemoveAt()
        {
            var target = new VstEventCollection
            {
                new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0),
                new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0)
            };

            target.Should().HaveCount(2);

            int callCount = 0;

            target.CollectionChanged += (sender, e) =>
            {
                e.Action.Should().Be(NotifyCollectionChangedAction.Remove);
                e.OldItems.Should().NotBeNullOrEmpty();
                e.OldItems[0].Should().NotBeNull();

                callCount++;
            };

            target.RemoveAt(0);
            target.RemoveAt(0);

            callCount.Should().Be(2);
            target.Should().BeEmpty();
        }
예제 #2
0
        public void Test_VstEventCollection_CollectionChanged_RemoveAt()
        {
            VstEventCollection target = new VstEventCollection();

            target.Add(new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0));
            target.Add(new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0));

            Assert.AreEqual(2, target.Count, "Collection Count is not as expected.");

            int callCount = 0;

            target.CollectionChanged += (sender, e) =>
            {
                Assert.AreEqual(NotifyCollectionChangedAction.Remove, e.Action, "Unexpected collection changed action.");
                Assert.IsNotNull(e.NewItems, "NewItems collection is null.");
                Assert.AreEqual(0, e.NewItems.Count, "Not the expected number of items in the NewItems collection.");
                Assert.IsNotNull(e.OldItems, "OldItems collection is null.");
                Assert.AreEqual(1, e.OldItems.Count, "Not the expected number of items in the OldItems collection.");
                Assert.IsNotNull(e.OldItems[0], "OldItems[0] is null.");

                callCount++;
            };

            target.RemoveAt(0);
            target.RemoveAt(0);

            Assert.AreEqual(2, callCount, "Call count is not as expected.");
        }