-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserInMemoryTests.cs
81 lines (67 loc) · 2.43 KB
/
UserInMemoryTests.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
78
79
80
81
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;
using WalletDomain;
using WalletDomain.Domain;
using WalletDomain.Services;
using WalletDomain.Services.InMemory;
namespace WalletTest
{
[TestClass]
public class UserInMemoryTests
{
[TestMethod]
public void Can_Add_User_To_Repository()
{
//Arrange
IUserService userService = new UserService();
//Assert
var result = userService.Add(new User("TestUsername", "test@email.com", "testPassword"));
//Act
Assert.AreEqual(true, result);
}
[TestMethod]
public void Can_Get_Existing_User()
{
//Arrange
IUserService userService = new UserService();
var user = new User("TestUsername", "test@email.com", "testPassword");
//Act
var addUserToRepoResponse = userService.Add(user);
var getUserResponse = userService.GetById(user.Id);
//Assert
Assert.AreEqual(true, addUserToRepoResponse);
Assert.AreEqual(user, getUserResponse);
}
[TestMethod]
public void Cant_Get_Not_Existing_User()
{
//Arrange
IUserService userService = new UserService();
//Act
var getUserResponse = userService.GetById(1);
//Assert
Assert.AreEqual(null, getUserResponse);
}
[TestMethod]
public void Can_Update_User()
{
//Arrange
IUserService userService = new UserService();
var user = new User("TestUsername", "test@email.com", "testPassword");
//Act
userService.Add(user);
var userResponse = userService.GetById(user.Id);
userResponse.SetUsername("NewTestUserName");
userResponse.SetEmail("newTest@email.com");
userResponse.SetPassword("newTestPassword");
userService.Update(userResponse);
var userResponse2 = userService.GetById(userResponse.Id);
//Assert
Assert.AreEqual("NewTestUserName", userResponse2.Username);
Assert.AreEqual("newTest@email.com", userResponse2.Email);
Assert.AreEqual("newTestPassword", userResponse2.Password);
}
}
}