-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserTests.cs
77 lines (65 loc) · 2.52 KB
/
UserTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WalletDomain;
using WalletDomain.Domain;
using WalletDomain.Exceptions;
namespace WalletTest
{
[TestClass]
public class UserTests
{
[TestMethod]
public void Can_Change_Username()
{
//Arrange
var user = new User("username1", "email1@email.com", "password1");
//Act
user.SetUsername("username2");
//Assert
Assert.AreEqual("username2", user.Username);
}
[TestMethod]
public void Can_Change_User_Email()
{
//Arrange
var user = new User("username1", "email1@email.com", "password1");
//Act
user.SetEmail("email2@email.com");
//Assert
Assert.AreEqual("email2@email.com", user.Email);
}
[TestMethod]
public void Can_Change_User_Password()
{
//Arrange
var user = new User("username1", "email1@email.com", "password1");
//Act
user.SetPassword("password2");
//Assert
Assert.AreEqual("password2", user.Password);
}
[TestMethod]
public void Cant_Set_Invalid_Email()
{
//Arrange Act Assert
Assert.ThrowsException<EmailException>(() => new User("username", "", "password"));
Assert.ThrowsException<EmailException>(() => new User("username", "wrongEmail", "password"));
Assert.ThrowsException<EmailException>(() => new User("username", "wrongEmail@", "password"));
Assert.ThrowsException<EmailException>(() => new User("username", "@wrongEmail", "password"));
Assert.ThrowsException<EmailException>(() => new User("username", "wrongemail@email..com", "password"));
Assert.ThrowsException<EmailException>(() => new User("username", "wrong..email@email.com", "password"));
}
[TestMethod]
public void Cant_Set_Invalid_Username()
{
//Arrange Act Assert
Assert.ThrowsException<UsernameException>(() => new User("", "email@emal.com", "password"));
}
[TestMethod]
public void Cant_Set_Invalid_Password()
{
//Arrange Act Assert
Assert.ThrowsException<PasswordException>(() => new User("username", "email@email.com", ""));
}
}
}