Пример #1
0
        public void TestPropertyChangedException()
        {
            var x = new NotifyPropertyChangedMock();

            x.PropertyChanged += (sender, args) => { throw new Exception("TEST"); };

            Assert.Throws <AggregateException>(() => { x.IntPropertyA = 88; });
        }
Пример #2
0
        public void TestPropertyChangedNoChange()
        {
            var x = new NotifyPropertyChangedMock();

            x.IntPropertyA = 88;

            PropertyChangedEventArgs eventArgs = null;

            x.PropertyChanged += (sender, args) => { eventArgs = args; };

            x.IntPropertyA = 88;

            Assert.Null(eventArgs);
        }
Пример #3
0
        public void TestPropertyChangedSuspended()
        {
            var x = new NotifyPropertyChangedMock();

            PropertyChangedEventArgs eventArgs = null;

            x.PropertyChanged += (sender, args) => { eventArgs = args; };

            x.DisablePropertyChangedEvents();

            x.IntPropertyA = 99;

            x.EnablePropertyChangedEvents();

            Assert.Null(eventArgs);

            //TODO: Validate that this is per-thread.
        }
Пример #4
0
        public void TestPropertyChanged()
        {
            var x = new NotifyPropertyChangedMock();

            PropertyChangedEventArgs eventArgs = null;

            x.PropertyChanged += (sender, args) => { eventArgs = args; };

            x.IntPropertyA = 88;

            Assert.NotNull(eventArgs);
            Assert.Equal(nameof(NotifyPropertyChangedMock.IntPropertyA), eventArgs.PropertyName);
            Assert.True(x.LastPropertyAssignmentWasChange);

            eventArgs = null;

            x.IntPropertyA = 88;

            Assert.Null(eventArgs);
            Assert.False(x.LastPropertyAssignmentWasChange);
        }