annotate 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
rev   line source
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
1 using System;
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
2 using FluentAssertions.EventMonitoring;
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
3 using NUnit.Framework;
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
4 using SilverlightValidation.Models;
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
5 using SilverlightValidation.Tests.Fakes;
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
6 using SilverlightValidation.Validators;
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
7 using SilverlightValidation.ViewModels;
96
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
8
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
9 namespace SilverlightValidation.Tests.ViewModels
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
10 {
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
11 [TestFixture]
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
12 class UserViewModelFixture
96
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
13 {
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
14 #region Constructor
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
15
96
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
16 [Test]
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
17 public void WhenConstructed_WithTwoNulls_ThenArgumentNullExceptionForModel()
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
18 {
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
19 Assert.Throws<ArgumentNullException>(() => new UserViewModel(null, null), "model");
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
20 }
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
21
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
22 [Test]
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
23 public void WhenConstructed_WithNullFirstParam_ThenArgumentNullExceptionForModel()
96
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
24 {
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
25 Assert.Throws<ArgumentNullException>(() => new UserViewModel(null, UserModelValidator.Create()), "model");
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
26 }
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
27
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
28 [Test]
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
29 public void WhenConstructed_WithNullSecondParam_ThenArgumentNullExceptionForValidator()
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
30 {
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
31 Assert.Throws<ArgumentNullException>(() => new UserViewModel(UserModel.Create(), null), "validator");
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
32 }
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
33
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
34 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
35 public void WhenConstructed_WithGenericParams_ThenInstantiatesViewModel()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
36 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
37 var vm = new UserViewModel(UserModel.Create(), UserModelValidator.Create());
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
38 Assert.IsNotNull(vm);
96
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
39 }
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
40
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
41 #endregion
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
42
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
43 #region INotifyPropertyChanged
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
44
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
45 [Test]
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
46 public void WhenPropertyChanged_WithValidDateOfBirthUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
47 {
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
48 // arrange
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
49 var vm = CreateDefaultUserViewModel();
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
50
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
51 // act
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
52 vm.DateOfBirth = new DateTime(1977, 01, 01);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
53
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
54 // assert
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
55 vm.ShouldRaisePropertyChangeFor(x => x.DateOfBirth);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
56 Assert.IsTrue(vm.IsChanged);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
57 }
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
58
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
59
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
60 [Test]
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
61 public void WhenPropertyChanged_WithInvalidDateOfBirthUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
62 {
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
63 // arrange
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
64 var vm = CreateDefaultUserViewModel();
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
65
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
66 // act
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
67 vm.DateOfBirth = new DateTime(1800, 01, 01);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
68
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
69 // assert
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
70 vm.ShouldRaisePropertyChangeFor(x => x.DateOfBirth);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
71 Assert.IsTrue(vm.IsChanged);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
72 }
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
73
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
74 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
75 public void WhenPropertyChanged_WithDescriptionUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
76 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
77 // arrange
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
78 var vm = CreateDefaultUserViewModel();
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
79
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
80 // act
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
81 vm.Description = "New description";
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
82
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
83 // assert
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
84 vm.ShouldRaisePropertyChangeFor(x => x.Description);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
85 Assert.IsTrue(vm.IsChanged);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
86 }
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
87
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
88 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
89 public void WhenPropertyChanged_WithValidEmailUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
90 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
91 // arrange
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
92 var vm = CreateDefaultUserViewModel();
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
93
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
94 // act
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
95 vm.Email = "test@domain.com";
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
96
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
97 // assert
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
98 vm.ShouldRaisePropertyChangeFor(x => x.Email);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
99 Assert.IsTrue(vm.IsChanged);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
100 }
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
101
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
102 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
103 public void WhenPropertyChanged_WithInvalidEmailUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
104 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
105 // arrange
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
106 var vm = CreateDefaultUserViewModel();
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
107
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
108 // act
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
109 vm.Email = "invalid email";
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
110
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
111 // assert
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
112 vm.ShouldRaisePropertyChangeFor(x => x.Email);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
113 Assert.IsTrue(vm.IsChanged);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
114 }
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
115
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
116 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
117 public void WhenPropertyChanged_WithValidUsernameUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
118 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
119 // arrange
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
120 var vm = CreateDefaultUserViewModel();
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
121
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
122 // act
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
123 vm.Username = "dummy";
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
124
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
125 // assert
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
126 vm.ShouldRaisePropertyChangeFor(x => x.Username);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
127 Assert.IsTrue(vm.IsChanged);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
128 }
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
129
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
130 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
131 public void WhenPropertyChanged_WithInvalidUsernameUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
132 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
133 // arrange
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
134 var vm = CreateDefaultUserViewModel();
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
135
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
136 // act
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
137 vm.Username = "invalidusernametoolong";
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
138
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
139 // assert
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
140 vm.ShouldRaisePropertyChangeFor(x => x.Username);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
141 Assert.IsTrue(vm.IsChanged);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
142 }
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
143
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
144 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
145 public void WhenPropertyChanged_WithValidPasswordUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
146 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
147 // arrange
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
148 var vm = CreateDefaultUserViewModel();
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
149
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
150 // act
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
151 vm.Password = "dummy";
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
152
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
153 // assert
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
154 vm.ShouldRaisePropertyChangeFor(x => x.Password);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
155 Assert.IsTrue(vm.IsChanged);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
156 }
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
157
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
158 [Test]
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
159 public void WhenPropertyChanged_WithInvalidPasswordUpdated_ThenFiresChangeEventAndIsChangedEqualsTrue()
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
160 {
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
161 // arrange
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
162 var vm = CreateDefaultUserViewModel();
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
163
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
164 // act
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
165 vm.Password = "invalidpasswordtoolong";
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
166
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
167 // assert
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
168 vm.ShouldRaisePropertyChangeFor(x => x.Password);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
169 Assert.IsTrue(vm.IsChanged);
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
170 }
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
171
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
172 #endregion
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
173
106
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
174 #region Commands
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
175
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
176 [Test]
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
177 public void WhenNewViewModel_ThenOkCommandIsExecutable()
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
178 {
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
179 // arrange
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
180 var vm = CreateDefaultUserViewModel();
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
181
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
182 // assert
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
183 Assert.IsTrue(vm.OkCommand.CanExecute(null));
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
184 }
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
185
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
186 [Test]
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
187 public void WhenNewViewModel_ThenCancelCommandIsExecutable()
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
188 {
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
189 // arrange
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
190 var vm = CreateDefaultUserViewModel();
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
191
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
192 // assert
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
193 Assert.IsTrue(vm.CancelCommand.CanExecute(null));
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
194 }
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
195
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
196 [Test]
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
197 public void WhenNewViewModel_WithCancelExecuted_ThenShouldRaiseEvent()
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
198 {
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
199 // arrange
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
200 var vm = CreateDefaultUserViewModel();
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
201
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
202 // act
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
203 vm.CancelCommand.Execute(null);
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
204
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
205 // assert
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
206 vm.ShouldRaise("UserViewResponseMessage");
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
207 }
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
208
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
209 #endregion
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
210
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
211 #region Helpers
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
212
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
213 private static UserViewModel CreateDefaultUserViewModel()
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
214 {
102
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
215 var vm = new UserViewModel(UserModel.Create(), UserModelValidatorFake.Create());
db05a55e3536 INPC tests added
stevenhollidge <stevenhollidge@hotmail.com>
parents: 98
diff changeset
216 vm.MonitorEvents();
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
217 return vm;
97
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
218 }
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
219
1adc1ae981ea Tests added to SilverlightValidation.Tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 96
diff changeset
220 #endregion
96
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
221 }
188f8b366e87 Unit test project correctly setup as normal class library DLL.
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
222 }