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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
46 #endregion
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
47
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
48 #region INotifyPropertyChanged
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
52 {
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
53 // arrange
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
54 var vm = CreateDefaultUserViewModel();
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
55
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
56 // act
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
57 vm.DateOfBirth = new DateTime(1977, 01, 01);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
58
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
59 // assert
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
60 vm.ShouldRaisePropertyChangeFor(x => x.DateOfBirth);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
61 Assert.IsTrue(vm.IsChanged);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
62 }
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
67 {
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
68 // arrange
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
84
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
85 // act
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
86 vm.Description = "New description";
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
87
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
88 // assert
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
89 vm.ShouldRaisePropertyChangeFor(x => x.Description);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
90 Assert.IsTrue(vm.IsChanged);
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
91 }
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
176
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
177 #endregion
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
178
106
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
179 #region Commands
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
180
107
572886951353 Working tests under StatLight
stevenhollidge <stevenhollidge@hotmail.com>
parents: 106
diff changeset
181 [TestMethod]
106
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
182 public void WhenNewViewModel_ThenOkCommandIsExecutable()
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
183 {
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
184 // arrange
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
185 var vm = CreateDefaultUserViewModel();
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
186
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
187 // assert
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
188 Assert.IsTrue(vm.OkCommand.CanExecute(null));
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
189 }
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
190
107
572886951353 Working tests under StatLight
stevenhollidge <stevenhollidge@hotmail.com>
parents: 106
diff changeset
191 [TestMethod]
106
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
192 public void WhenNewViewModel_ThenCancelCommandIsExecutable()
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
193 {
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
194 // arrange
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
195 var vm = CreateDefaultUserViewModel();
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
196
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
197 // assert
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
198 Assert.IsTrue(vm.CancelCommand.CanExecute(null));
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
199 }
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
200
107
572886951353 Working tests under StatLight
stevenhollidge <stevenhollidge@hotmail.com>
parents: 106
diff changeset
201 [TestMethod]
106
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
202 public void WhenNewViewModel_WithCancelExecuted_ThenShouldRaiseEvent()
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
203 {
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
204 // arrange
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
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
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
208
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
209 // act
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
210 vm.CancelCommand.Execute(null);
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
211
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
212 // assert
107
572886951353 Working tests under StatLight
stevenhollidge <stevenhollidge@hotmail.com>
parents: 106
diff changeset
213 Assert.IsTrue(hasMessage);
106
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
214 }
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
215
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
216 #endregion
62477c2e8837 Command tests
stevenhollidge <stevenhollidge@hotmail.com>
parents: 102
diff changeset
217
98
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
218 #region Helpers
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
219
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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
d0c2cac12376 Latest version
stevenhollidge <stevenhollidge@hotmail.com>
parents: 97
diff changeset
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 }