コード例 #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);
        }