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