示例#1
0
        public void TestDependencyProperties()
        {
            //Arrange

            WPFMammal vm;
            IMammal   dog;

            //Act
            dog = new Dog();
            vm  = new WPFMammal(dog);

            string dogNamePrev = dog.Name;
            string vmNamePres  = vm.Name;

            bool gotEvent = false;

            ((INotifyPropertyChanged)vm).PropertyChanged +=
                delegate(object sender, PropertyChangedEventArgs e)
            {
                gotEvent = true;
                Assert.AreEqual <string>("Name", e.PropertyName);
            };

            string newValue = "NewName";

            vm.Name = newValue;

            Assert.AreEqual <string>(newValue, vm.Name, "View Model Changed");

            //Assert
            Assert.IsInstanceOfType(vm, typeof(INotifyPropertyChanged));
            Assert.IsTrue(gotEvent, "Didn’t get the PropertyChanged event.");
        }
示例#2
0
 public WPFMammalTest()
 {
     wpfMammal = new WPFMammal(new Dog());
 }