public void DeferredNotificationsDontShowUpUntilUndeferred()
        {
            var fixture = new TestFixture();

            fixture.Changing.ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var changing).Subscribe();
            fixture.Changed.ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var changed).Subscribe();
            var propertyChangingEvents = new List <PropertyChangingEventArgs>();

            fixture.PropertyChanging += (sender, args) => propertyChangingEvents.Add(args);
            var propertyChangedEvents = new List <PropertyChangedEventArgs>();

            fixture.PropertyChanged += (sender, args) => propertyChangedEvents.Add(args);

            AssertCount(0, changing, changed, propertyChangingEvents, propertyChangedEvents);
            fixture.NullableInt = 4;
            AssertCount(1, changing, changed, propertyChangingEvents, propertyChangedEvents);

            var stopDelaying = fixture.DelayChangeNotifications();

            fixture.NullableInt = 5;
            AssertCount(1, changing, changed, propertyChangingEvents, propertyChangedEvents);

            fixture.IsNotNullString = "Bar";
            AssertCount(1, changing, changed, propertyChangingEvents, propertyChangedEvents);

            fixture.NullableInt = 6;
            AssertCount(1, changing, changed, propertyChangingEvents, propertyChangedEvents);

            fixture.IsNotNullString = "Baz";
            AssertCount(1, changing, changed, propertyChangingEvents, propertyChangedEvents);

            var stopDelayingMore = fixture.DelayChangeNotifications();

            fixture.IsNotNullString = "Bamf";
            AssertCount(1, changing, changed, propertyChangingEvents, propertyChangedEvents);

            stopDelaying.Dispose();

            fixture.IsNotNullString = "Blargh";
            AssertCount(1, changing, changed, propertyChangingEvents, propertyChangedEvents);

            // NB: Because we debounce queued up notifications, we should only
            // see a notification from the latest NullableInt and the latest
            // IsNotNullableString
            stopDelayingMore.Dispose();

            AssertCount(3, changing, changed, propertyChangingEvents, propertyChangedEvents);

            var expectedEventProperties = new[] { "NullableInt", "NullableInt", "IsNotNullString" };

            Assert.Equal(expectedEventProperties, changing.Select(e => e.PropertyName));
            Assert.Equal(expectedEventProperties, changed.Select(e => e.PropertyName));
            Assert.Equal(expectedEventProperties, propertyChangingEvents.Select(e => e.PropertyName));
            Assert.Equal(expectedEventProperties, propertyChangedEvents.Select(e => e.PropertyName));
        }
Exemplo n.º 2
0
        public void DeferringNotificationsDontShowUpUntilUndeferred()
        {
            var fixture = new TestFixture();

            fixture.Changed.ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var output).Subscribe();

            Assert.Equal(0, output.Count);
            fixture.NullableInt = 4;
            Assert.Equal(1, output.Count);

            var stopDelaying = fixture.DelayChangeNotifications();

            fixture.NullableInt = 5;
            Assert.Equal(1, output.Count);

            fixture.IsNotNullString = "Bar";
            Assert.Equal(1, output.Count);

            fixture.NullableInt = 6;
            Assert.Equal(1, output.Count);

            fixture.IsNotNullString = "Baz";
            Assert.Equal(1, output.Count);

            var stopDelayingMore = fixture.DelayChangeNotifications();

            fixture.IsNotNullString = "Bamf";
            Assert.Equal(1, output.Count);

            stopDelaying.Dispose();

            fixture.IsNotNullString = "Blargh";
            Assert.Equal(1, output.Count);

            // NB: Because we debounce queued up notifications, we should only
            // see a notification from the latest NullableInt and the latest
            // IsNotNullableString
            stopDelayingMore.Dispose();
            Assert.Equal(3, output.Count);
        }
Exemplo n.º 3
0
        public void DeferringNotificationsDontShowUpUntilUndeferred()
        {
            var fixture = new TestFixture();
            var output  = fixture.Changed.CreateCollection();

            Assert.Equal(0, output.Count);
            fixture.NullableInt = 4;
            Assert.Equal(1, output.Count);

            var stopDelaying = fixture.DelayChangeNotifications();

            fixture.NullableInt = 5;
            Assert.Equal(1, output.Count);

            fixture.IsNotNullString = "Bar";
            Assert.Equal(1, output.Count);

            fixture.NullableInt = 6;
            Assert.Equal(1, output.Count);

            fixture.IsNotNullString = "Baz";
            Assert.Equal(1, output.Count);

            var stopDelayingMore = fixture.DelayChangeNotifications();

            fixture.IsNotNullString = "Bamf";
            Assert.Equal(1, output.Count);

            stopDelaying.Dispose();

            fixture.IsNotNullString = "Blargh";
            Assert.Equal(1, output.Count);

            // NB: Because we debounce queued up notifications, we should only
            // see a notification from the latest NullableInt and the latest
            // IsNotNullableString
            stopDelayingMore.Dispose();
            Assert.Equal(3, output.Count);
        }
Exemplo n.º 4
0
        public void DeferringNotificationsDontShowUpUntilUndeferred()
        {
            var fixture = new TestFixture();
            var output = fixture.Changed.CreateCollection();

            Assert.Equal(0, output.Count);
            fixture.NullableInt = 4;
            Assert.Equal(1, output.Count);

            var stopDelaying = fixture.DelayChangeNotifications();

            fixture.NullableInt = 5;
            Assert.Equal(1, output.Count);

            fixture.IsNotNullString = "Bar";
            Assert.Equal(1, output.Count);

            fixture.NullableInt = 6;
            Assert.Equal(1, output.Count);

            fixture.IsNotNullString = "Baz";
            Assert.Equal(1, output.Count);

            var stopDelayingMore = fixture.DelayChangeNotifications();

            fixture.IsNotNullString = "Bamf";
            Assert.Equal(1, output.Count);

            stopDelaying.Dispose();

            fixture.IsNotNullString = "Blargh";
            Assert.Equal(1, output.Count);

            // NB: Because we debounce queued up notifications, we should only
            // see a notification from the latest NullableInt and the latest
            // IsNotNullableString
            stopDelayingMore.Dispose();
            Assert.Equal(3, output.Count);
        }