1 | using System;
|
---|
2 | using System.Collections.Specialized;
|
---|
3 | using Service.Provider;
|
---|
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
5 | using System.Web.Security;
|
---|
6 | using Persistence;
|
---|
7 | using System.Linq;
|
---|
8 | using System.Collections.Generic;
|
---|
9 |
|
---|
10 | namespace UnitTests {
|
---|
11 | /// <summary>
|
---|
12 | ///This is a test class for HeuristicLabMembershipProviderTest and is intended
|
---|
13 | ///to contain all HeuristicLabMembershipProviderTest Unit Tests
|
---|
14 | ///</summary>
|
---|
15 | [TestClass()]
|
---|
16 | public class HeuristicLabMembershipProviderTest : AbstractHeuristicLabTest {
|
---|
17 | private TestContext testContextInstance;
|
---|
18 |
|
---|
19 | /// <summary>
|
---|
20 | ///Gets or sets the test context which provides
|
---|
21 | ///information about and functionality for the current test run.
|
---|
22 | ///</summary>
|
---|
23 | public TestContext TestContext {
|
---|
24 | get {
|
---|
25 | return testContextInstance;
|
---|
26 | }
|
---|
27 | set {
|
---|
28 | testContextInstance = value;
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | #region Additional test attributes
|
---|
33 | //
|
---|
34 | //You can use the following additional attributes as you write your tests:
|
---|
35 | //
|
---|
36 | //Use ClassInitialize to run code before running the first test in the class
|
---|
37 | //[ClassInitialize()]
|
---|
38 | //public static void MyClassInitialize(TestContext testContext)
|
---|
39 | //{
|
---|
40 | //}
|
---|
41 | //
|
---|
42 | //Use ClassCleanup to run code after all tests in a class have run
|
---|
43 | //[ClassCleanup()]
|
---|
44 | //public static void MyClassCleanup()
|
---|
45 | //{
|
---|
46 | //}
|
---|
47 | //
|
---|
48 | //Use TestInitialize to run code before running each test
|
---|
49 | //[TestInitialize()]
|
---|
50 | //public void MyTestInitialize()
|
---|
51 | //{
|
---|
52 | //}
|
---|
53 | //
|
---|
54 | //Use TestCleanup to run code after each test has run
|
---|
55 | //[TestCleanup()]
|
---|
56 | //public void MyTestCleanup()
|
---|
57 | //{
|
---|
58 | //}
|
---|
59 | //
|
---|
60 | #endregion
|
---|
61 |
|
---|
62 |
|
---|
63 | /// <summary>
|
---|
64 | ///A test for RequiresUniqueEmail
|
---|
65 | ///</summary>
|
---|
66 | [TestMethod()]
|
---|
67 | public void RequiresUniqueEmailTest() {
|
---|
68 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
69 | bool actual;
|
---|
70 | actual = target.RequiresUniqueEmail;
|
---|
71 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
72 | }
|
---|
73 |
|
---|
74 | /// <summary>
|
---|
75 | ///A test for RequiresQuestionAndAnswer
|
---|
76 | ///</summary>
|
---|
77 | [TestMethod()]
|
---|
78 | public void RequiresQuestionAndAnswerTest() {
|
---|
79 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
80 | bool actual;
|
---|
81 | actual = target.RequiresQuestionAndAnswer;
|
---|
82 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
83 | }
|
---|
84 |
|
---|
85 | /// <summary>
|
---|
86 | ///A test for PasswordStrengthRegularExpression
|
---|
87 | ///</summary>
|
---|
88 | [TestMethod()]
|
---|
89 | public void PasswordStrengthRegularExpressionTest() {
|
---|
90 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
91 | string actual;
|
---|
92 | actual = target.PasswordStrengthRegularExpression;
|
---|
93 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
94 | }
|
---|
95 |
|
---|
96 | /// <summary>
|
---|
97 | ///A test for PasswordFormat
|
---|
98 | ///</summary>
|
---|
99 | [TestMethod()]
|
---|
100 | public void PasswordFormatTest() {
|
---|
101 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
102 | MembershipPasswordFormat actual;
|
---|
103 | actual = target.PasswordFormat;
|
---|
104 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
105 | }
|
---|
106 |
|
---|
107 | /// <summary>
|
---|
108 | ///A test for PasswordAttemptWindow
|
---|
109 | ///</summary>
|
---|
110 | [TestMethod()]
|
---|
111 | public void PasswordAttemptWindowTest() {
|
---|
112 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
113 | int actual;
|
---|
114 | actual = target.PasswordAttemptWindow;
|
---|
115 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
116 | }
|
---|
117 |
|
---|
118 | /// <summary>
|
---|
119 | ///A test for MinRequiredPasswordLength
|
---|
120 | ///</summary>
|
---|
121 | [TestMethod()]
|
---|
122 | public void MinRequiredPasswordLengthTest() {
|
---|
123 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
124 | int actual;
|
---|
125 | actual = target.MinRequiredPasswordLength;
|
---|
126 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
127 | }
|
---|
128 |
|
---|
129 | /// <summary>
|
---|
130 | ///A test for MinRequiredNonAlphanumericCharacters
|
---|
131 | ///</summary>
|
---|
132 | [TestMethod()]
|
---|
133 | public void MinRequiredNonAlphanumericCharactersTest() {
|
---|
134 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
135 | int actual;
|
---|
136 | actual = target.MinRequiredNonAlphanumericCharacters;
|
---|
137 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
138 | }
|
---|
139 |
|
---|
140 | /// <summary>
|
---|
141 | ///A test for MaxInvalidPasswordAttempts
|
---|
142 | ///</summary>
|
---|
143 | [TestMethod()]
|
---|
144 | public void MaxInvalidPasswordAttemptsTest() {
|
---|
145 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
146 | int actual;
|
---|
147 | actual = target.MaxInvalidPasswordAttempts;
|
---|
148 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
149 | }
|
---|
150 |
|
---|
151 | /// <summary>
|
---|
152 | ///A test for EnablePasswordRetrieval
|
---|
153 | ///</summary>
|
---|
154 | [TestMethod()]
|
---|
155 | public void EnablePasswordRetrievalTest() {
|
---|
156 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
157 | bool actual;
|
---|
158 | actual = target.EnablePasswordRetrieval;
|
---|
159 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
160 | }
|
---|
161 |
|
---|
162 | /// <summary>
|
---|
163 | ///A test for EnablePasswordReset
|
---|
164 | ///</summary>
|
---|
165 | [TestMethod()]
|
---|
166 | public void EnablePasswordResetTest() {
|
---|
167 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
168 | bool actual;
|
---|
169 | actual = target.EnablePasswordReset;
|
---|
170 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
171 | }
|
---|
172 |
|
---|
173 | /// <summary>
|
---|
174 | ///A test for ApplicationName
|
---|
175 | ///</summary>
|
---|
176 | [TestMethod()]
|
---|
177 | public void ApplicationNameTest() {
|
---|
178 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
179 | string expected = string.Empty; // TODO: Initialize to an appropriate value
|
---|
180 | string actual;
|
---|
181 | target.ApplicationName = expected;
|
---|
182 | actual = target.ApplicationName;
|
---|
183 | Assert.AreEqual(expected, actual);
|
---|
184 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
185 | }
|
---|
186 |
|
---|
187 | /// <summary>
|
---|
188 | ///A test for ValidateUser
|
---|
189 | ///</summary>
|
---|
190 | [TestMethod()]
|
---|
191 | public void ValidateUserTest() {
|
---|
192 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
193 | MembershipCreateStatus status;
|
---|
194 | target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status);
|
---|
195 | Assert.IsTrue(target.ValidateUser("testname", "newPassword"));
|
---|
196 | }
|
---|
197 |
|
---|
198 | /// <summary>
|
---|
199 | ///A test for ValidateUser
|
---|
200 | ///</summary>
|
---|
201 | [TestMethod()]
|
---|
202 | public void ValidateUserTestEncrypted() {
|
---|
203 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
204 | NameValueCollection config = new NameValueCollection();
|
---|
205 | config.Add("passwordFormat", "Encrypted");
|
---|
206 | target.Initialize("", config);
|
---|
207 | MembershipCreateStatus status;
|
---|
208 | target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status);
|
---|
209 | Assert.IsTrue(target.ValidateUser("testname", "newPassword"));
|
---|
210 | }
|
---|
211 |
|
---|
212 | /// <summary>
|
---|
213 | ///A test for ValidateUser
|
---|
214 | ///</summary>
|
---|
215 | [TestMethod()]
|
---|
216 | public void ValidateUserTestHashed() {
|
---|
217 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
218 | NameValueCollection config = new NameValueCollection();
|
---|
219 | config.Add("passwordFormat", "Hashed");
|
---|
220 | target.Initialize("",config);
|
---|
221 | MembershipCreateStatus status;
|
---|
222 | target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status);
|
---|
223 | Assert.IsTrue(target.ValidateUser("testname", "newPassword"));
|
---|
224 | }
|
---|
225 |
|
---|
226 | /// <summary>
|
---|
227 | ///A test for UpdateUser
|
---|
228 | ///</summary>
|
---|
229 | [TestMethod()]
|
---|
230 | public void UpdateUserTest() {
|
---|
231 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
232 | MembershipUser user = null; // TODO: Initialize to an appropriate value
|
---|
233 | target.UpdateUser(user);
|
---|
234 | Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
---|
235 | }
|
---|
236 |
|
---|
237 | /// <summary>
|
---|
238 | ///A test for UnlockUser
|
---|
239 | ///</summary>
|
---|
240 | [TestMethod()]
|
---|
241 | public void UnlockUserTest() {
|
---|
242 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
243 | string userName = string.Empty; // TODO: Initialize to an appropriate value
|
---|
244 | bool expected = false; // TODO: Initialize to an appropriate value
|
---|
245 | bool actual;
|
---|
246 | actual = target.UnlockUser(userName);
|
---|
247 | Assert.AreEqual(expected, actual);
|
---|
248 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
249 | }
|
---|
250 |
|
---|
251 | /// <summary>
|
---|
252 | ///A test for ResetPassword
|
---|
253 | ///</summary>
|
---|
254 | [TestMethod()]
|
---|
255 | public void ResetPasswordTest() {
|
---|
256 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
257 | string username = string.Empty; // TODO: Initialize to an appropriate value
|
---|
258 | string answer = string.Empty; // TODO: Initialize to an appropriate value
|
---|
259 | string expected = string.Empty; // TODO: Initialize to an appropriate value
|
---|
260 | string actual;
|
---|
261 | actual = target.ResetPassword(username, answer);
|
---|
262 | Assert.AreEqual(expected, actual);
|
---|
263 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
264 | }
|
---|
265 |
|
---|
266 | /// <summary>
|
---|
267 | ///A test for GetUserNameByEmail
|
---|
268 | ///</summary>
|
---|
269 | [TestMethod()]
|
---|
270 | public void GetUserNameByEmailTest() {
|
---|
271 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
272 | string email = string.Empty; // TODO: Initialize to an appropriate value
|
---|
273 | string expected = string.Empty; // TODO: Initialize to an appropriate value
|
---|
274 | string actual;
|
---|
275 | actual = target.GetUserNameByEmail(email);
|
---|
276 | Assert.AreEqual(expected, actual);
|
---|
277 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
278 | }
|
---|
279 |
|
---|
280 | /// <summary>
|
---|
281 | ///A test for GetUser
|
---|
282 | ///</summary>
|
---|
283 | [TestMethod()]
|
---|
284 | public void GetUserTest1() {
|
---|
285 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
286 | object providerUserKey = null; // TODO: Initialize to an appropriate value
|
---|
287 | bool userIsOnline = false; // TODO: Initialize to an appropriate value
|
---|
288 | MembershipUser expected = null; // TODO: Initialize to an appropriate value
|
---|
289 | MembershipUser actual;
|
---|
290 | actual = target.GetUser(providerUserKey, userIsOnline);
|
---|
291 | Assert.AreEqual(expected, actual);
|
---|
292 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
293 | }
|
---|
294 |
|
---|
295 | /// <summary>
|
---|
296 | ///A test for GetUser
|
---|
297 | ///</summary>
|
---|
298 | [TestMethod()]
|
---|
299 | public void GetUserTest() {
|
---|
300 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
301 | string username = string.Empty; // TODO: Initialize to an appropriate value
|
---|
302 | bool userIsOnline = false; // TODO: Initialize to an appropriate value
|
---|
303 | MembershipUser expected = null; // TODO: Initialize to an appropriate value
|
---|
304 | MembershipUser actual;
|
---|
305 | actual = target.GetUser(username, userIsOnline);
|
---|
306 | Assert.AreEqual(expected, actual);
|
---|
307 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
308 | }
|
---|
309 |
|
---|
310 | /// <summary>
|
---|
311 | ///A test for GetPassword
|
---|
312 | ///</summary>
|
---|
313 | [TestMethod()]
|
---|
314 | public void GetPasswordTest() {
|
---|
315 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
316 | string username = string.Empty; // TODO: Initialize to an appropriate value
|
---|
317 | string answer = string.Empty; // TODO: Initialize to an appropriate value
|
---|
318 | string expected = string.Empty; // TODO: Initialize to an appropriate value
|
---|
319 | string actual;
|
---|
320 | actual = target.GetPassword(username, answer);
|
---|
321 | Assert.AreEqual(expected, actual);
|
---|
322 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
323 | }
|
---|
324 |
|
---|
325 | /// <summary>
|
---|
326 | ///A test for GetNumberOfUsersOnline
|
---|
327 | ///</summary>
|
---|
328 | [TestMethod()]
|
---|
329 | public void GetNumberOfUsersOnlineTest() {
|
---|
330 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
331 | int expected = 0; // TODO: Initialize to an appropriate value
|
---|
332 | int actual;
|
---|
333 | actual = target.GetNumberOfUsersOnline();
|
---|
334 | Assert.AreEqual(expected, actual);
|
---|
335 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
336 | }
|
---|
337 |
|
---|
338 | /// <summary>
|
---|
339 | ///A test for GetAllUsers
|
---|
340 | ///</summary>
|
---|
341 | [TestMethod()]
|
---|
342 | public void GetAllUsersTest() {
|
---|
343 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
344 | int pageIndex = 0; // TODO: Initialize to an appropriate value
|
---|
345 | int pageSize = 0; // TODO: Initialize to an appropriate value
|
---|
346 | int totalRecords = 0; // TODO: Initialize to an appropriate value
|
---|
347 | int totalRecordsExpected = 0; // TODO: Initialize to an appropriate value
|
---|
348 | MembershipUserCollection expected = null; // TODO: Initialize to an appropriate value
|
---|
349 | MembershipUserCollection actual;
|
---|
350 | actual = target.GetAllUsers(pageIndex, pageSize, out totalRecords);
|
---|
351 | Assert.AreEqual(totalRecordsExpected, totalRecords);
|
---|
352 | Assert.AreEqual(expected, actual);
|
---|
353 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
354 | }
|
---|
355 |
|
---|
356 | /// <summary>
|
---|
357 | ///A test for FindUsersByName
|
---|
358 | ///</summary>
|
---|
359 | [TestMethod()]
|
---|
360 | public void FindUsersByNameTest() {
|
---|
361 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
362 | string usernameToMatch = string.Empty; // TODO: Initialize to an appropriate value
|
---|
363 | int pageIndex = 0; // TODO: Initialize to an appropriate value
|
---|
364 | int pageSize = 0; // TODO: Initialize to an appropriate value
|
---|
365 | int totalRecords = 0; // TODO: Initialize to an appropriate value
|
---|
366 | int totalRecordsExpected = 0; // TODO: Initialize to an appropriate value
|
---|
367 | MembershipUserCollection expected = null; // TODO: Initialize to an appropriate value
|
---|
368 | MembershipUserCollection actual;
|
---|
369 | actual = target.FindUsersByName(usernameToMatch, pageIndex, pageSize, out totalRecords);
|
---|
370 | Assert.AreEqual(totalRecordsExpected, totalRecords);
|
---|
371 | Assert.AreEqual(expected, actual);
|
---|
372 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
373 | }
|
---|
374 |
|
---|
375 | /// <summary>
|
---|
376 | ///A test for FindUsersByEmail
|
---|
377 | ///</summary>
|
---|
378 | [TestMethod()]
|
---|
379 | public void FindUsersByEmailTest() {
|
---|
380 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value
|
---|
381 | string emailToMatch = string.Empty; // TODO: Initialize to an appropriate value
|
---|
382 | int pageIndex = 0; // TODO: Initialize to an appropriate value
|
---|
383 | int pageSize = 0; // TODO: Initialize to an appropriate value
|
---|
384 | int totalRecords = 0; // TODO: Initialize to an appropriate value
|
---|
385 | int totalRecordsExpected = 0; // TODO: Initialize to an appropriate value
|
---|
386 | MembershipUserCollection expected = null; // TODO: Initialize to an appropriate value
|
---|
387 | MembershipUserCollection actual;
|
---|
388 | actual = target.FindUsersByEmail(emailToMatch, pageIndex, pageSize, out totalRecords);
|
---|
389 | Assert.AreEqual(totalRecordsExpected, totalRecords);
|
---|
390 | Assert.AreEqual(expected, actual);
|
---|
391 | Assert.Inconclusive("Verify the correctness of this test method.");
|
---|
392 | }
|
---|
393 |
|
---|
394 | /// <summary>
|
---|
395 | ///A test for DeleteUser
|
---|
396 | ///</summary>
|
---|
397 | [TestMethod()]
|
---|
398 | public void DeleteUserTest() {
|
---|
399 | // insert new user
|
---|
400 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
401 | MembershipCreateStatus status;
|
---|
402 | target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status);
|
---|
403 | Assert.AreEqual(MembershipCreateStatus.Success, status);
|
---|
404 |
|
---|
405 | // delete user
|
---|
406 | Assert.IsTrue(target.DeleteUser("testname", true));
|
---|
407 | Assert.AreEqual(0, db.HeuristicLabUsers.Count(x => x.UserName == "testname"));
|
---|
408 | }
|
---|
409 |
|
---|
410 | /// <summary>
|
---|
411 | ///A test for CreateUser
|
---|
412 | ///</summary>
|
---|
413 | [TestMethod()]
|
---|
414 | public void CreateUserTest() {
|
---|
415 | // create user
|
---|
416 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
417 | MembershipCreateStatus status;
|
---|
418 | target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status);
|
---|
419 | Assert.AreEqual(MembershipCreateStatus.Success, status);
|
---|
420 |
|
---|
421 | // check if user is OK
|
---|
422 | HeuristicLabUser u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname");
|
---|
423 | Assert.AreEqual<string>("testname", u.UserName);
|
---|
424 | Assert.AreEqual<string>("testemail", u.Email);
|
---|
425 | Assert.AreEqual<string>("newPassword", u.Password);
|
---|
426 | Assert.AreEqual<string>("testquestion", u.PasswordQuestion);
|
---|
427 | Assert.AreEqual<string>("testanswer", u.PasswordAnswer);
|
---|
428 | Assert.AreEqual<string>("", u.Comment);
|
---|
429 |
|
---|
430 | // check for duplicate errors
|
---|
431 | target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status);
|
---|
432 | Assert.AreEqual(MembershipCreateStatus.DuplicateUserName, status);
|
---|
433 | target.CreateUser("testname2", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status);
|
---|
434 | Assert.AreEqual(MembershipCreateStatus.DuplicateEmail, status);
|
---|
435 | }
|
---|
436 |
|
---|
437 | /// <summary>
|
---|
438 | ///A test for ChangePasswordQuestionAndAnswer
|
---|
439 | ///</summary>
|
---|
440 | [TestMethod()]
|
---|
441 | public void ChangePasswordQuestionAndAnswerTest() {
|
---|
442 | // create user
|
---|
443 | HeuristicLabUser u = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
|
---|
444 | db.HeuristicLabUsers.InsertOnSubmit(u);
|
---|
445 | db.SubmitChanges();
|
---|
446 |
|
---|
447 | // check if user is stored
|
---|
448 | u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname");
|
---|
449 | Assert.AreEqual<String>("testquestion", u.PasswordQuestion);
|
---|
450 | Assert.AreEqual<String>("", u.PasswordAnswer);
|
---|
451 |
|
---|
452 | // change data and check again
|
---|
453 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
454 | // gibt zwar true zurück, was schon mal gut ist
|
---|
455 | Assert.IsTrue(target.ChangePasswordQuestionAndAnswer("testname", "INIT", "newquestion", "newanswer"));
|
---|
456 | // aber hier ist die änderung noch nicht da!! es ist immer noch die alte frage + alte antwort
|
---|
457 | u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname");
|
---|
458 | Assert.AreEqual<String>("newquestion", u.PasswordQuestion);
|
---|
459 | Assert.AreEqual<String>("newanswer", u.PasswordAnswer);
|
---|
460 | }
|
---|
461 |
|
---|
462 | /// <summary>
|
---|
463 | ///A test for ChangePassword
|
---|
464 | ///</summary>
|
---|
465 | [TestMethod()]
|
---|
466 | public void ChangePasswordTest() {
|
---|
467 | // create user
|
---|
468 | HeuristicLabUser u = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
|
---|
469 | db.HeuristicLabUsers.InsertOnSubmit(u);
|
---|
470 | db.SubmitChanges();
|
---|
471 |
|
---|
472 | // check if user is stored
|
---|
473 | u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname");
|
---|
474 | Assert.AreEqual<String>("INIT", u.Password);
|
---|
475 |
|
---|
476 | // change data and check again
|
---|
477 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
478 | Assert.IsTrue(target.ChangePassword("testname", "INIT", "newPassword"));
|
---|
479 | // hat nix gemacht!! :(
|
---|
480 | u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname");
|
---|
481 | Assert.AreEqual<String>("newPassword", u.Password);
|
---|
482 | }
|
---|
483 |
|
---|
484 | /// <summary>
|
---|
485 | ///A test for HeuristicLabMembershipProvider Constructor
|
---|
486 | ///</summary>
|
---|
487 | [TestMethod()]
|
---|
488 | public void HeuristicLabMembershipProviderConstructorTest() {
|
---|
489 | HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider();
|
---|
490 | Assert.Inconclusive("TODO: Implement code to verify target");
|
---|
491 | }
|
---|
492 | }
|
---|
493 | }
|
---|