diff SilverlightValidation/SilverlightValidation.Tests/ViewModels/UserViewModelTests.cs @ 98:d0c2cac12376

Latest version
author stevenhollidge <stevenhollidge@hotmail.com>
date Sat, 05 May 2012 22:53:40 +0100
parents 1adc1ae981ea
children
line wrap: on
line diff
--- a/SilverlightValidation/SilverlightValidation.Tests/ViewModels/UserViewModelTests.cs	Sat May 05 16:39:00 2012 +0100
+++ b/SilverlightValidation/SilverlightValidation.Tests/ViewModels/UserViewModelTests.cs	Sat May 05 22:53:40 2012 +0100
@@ -1,4 +1,5 @@
 using System;
+using FluentAssertions.EventMonitoring;
 using NUnit.Framework;
 using SilverlightValidation.Models;
 using SilverlightValidation.Validators;
@@ -9,7 +10,7 @@
     [TestFixture]
     class UserViewModelTests
     {
-        #region constructor tests
+        #region Constructor
 
         [Test]
         public void Constructor_WhenTwoNulls_ThenArgumentNullExceptionForModel()
@@ -29,12 +30,56 @@
             Assert.Throws<ArgumentNullException>(() => new UserViewModel(new UserModel(), null), "validator");
         }
 
+        #endregion
+
+        #region INotifyPropertyChanged
+
         [Test]
-        public void DateOfBirth_WhenUpdated_ThenFiresPropertyChangeEvent()
+        public void PropertyChange_WhenDateOfBirthUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
+        {
+            // arrange
+            var vm = CreateDefaultUserViewModel();
+            vm.MonitorEvents();
+
+            // act
+            vm.DateOfBirth = new DateTime(1977, 01, 01);
+
+            // assert
+            vm.ShouldRaisePropertyChangeFor(x => x.DateOfBirth);
+            Assert.IsTrue(vm.IsChanged);
+        }
+
+        [Test]
+        public void PropertyChange_WhenDescriptionUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
+        {
+            // arrange
+            var vm = CreateDefaultUserViewModel();
+            vm.MonitorEvents();
+            
+            // act
+            vm.Description = "New description";
+
+            // assert
+            vm.ShouldRaisePropertyChangeFor(x => x.Description);
+            Assert.IsTrue(vm.IsChanged);
+        }
+
+        #endregion
+
+        #region INotifyDataErrorInfo
+
+        #endregion
+
+        #region Commands
+
+        #endregion
+
+        #region Helpers
+
+        private static UserViewModel CreateDefaultUserViewModel()
         {
             var vm = new UserViewModel(new UserModel(), new UserModelValidator());
-            var tester = new NotifyPropertyChangedTester(vm);
-            //tester.AssertChange();
+            return vm;
         }
 
         #endregion