diff SilverlightValidation/SilverlightValidation.Tests/ViewModels/UserViewModelFixture.cs @ 106:62477c2e8837

Command tests
author stevenhollidge <stevenhollidge@hotmail.com>
date Sun, 06 May 2012 13:00:46 +0100
parents db05a55e3536
children 572886951353
line wrap: on
line diff
--- a/SilverlightValidation/SilverlightValidation.Tests/ViewModels/UserViewModelFixture.cs	Sun May 06 12:32:35 2012 +0100
+++ b/SilverlightValidation/SilverlightValidation.Tests/ViewModels/UserViewModelFixture.cs	Sun May 06 13:00:46 2012 +0100
@@ -171,6 +171,43 @@
 
         #endregion
 
+        #region Commands
+
+        [Test]
+        public void WhenNewViewModel_ThenOkCommandIsExecutable()
+        {
+            // arrange
+            var vm = CreateDefaultUserViewModel();
+
+            // assert
+            Assert.IsTrue(vm.OkCommand.CanExecute(null));
+        }
+
+        [Test]
+        public void WhenNewViewModel_ThenCancelCommandIsExecutable()
+        {
+            // arrange
+            var vm = CreateDefaultUserViewModel();
+
+            // assert
+            Assert.IsTrue(vm.CancelCommand.CanExecute(null));
+        }
+
+        [Test]
+        public void WhenNewViewModel_WithCancelExecuted_ThenShouldRaiseEvent()
+        {
+            // arrange
+            var vm = CreateDefaultUserViewModel();
+
+            // act
+            vm.CancelCommand.Execute(null);
+
+            // assert
+            vm.ShouldRaise("UserViewResponseMessage");
+        }
+        
+        #endregion
+
         #region Helpers
 
         private static UserViewModel CreateDefaultUserViewModel()