-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements about the update of a user
- Loading branch information
1 parent
d48c147
commit acf5003
Showing
7 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -592,13 +592,36 @@ public void UpdateValidUser() | |
user.Name = "Gonzalo"; | ||
var userRepositoryMock = new Mock<IUserRepository>(MockBehavior.Strict); | ||
userRepositoryMock.Setup(m => m.Get(It.IsAny<Guid>())).Returns(user); | ||
userRepositoryMock.Setup(m => m.GetUserByEmail(It.IsAny<string>())).Returns(value: null); | ||
userRepositoryMock.Setup(m => m.Update(It.IsAny<User>())); | ||
var userLogic = new UserManagement(userRepositoryMock.Object); | ||
var result = userLogic.UpdateUser(user.Id, user); | ||
userRepositoryMock.VerifyAll(); | ||
Assert.AreEqual("Gonzalo", user.Name); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(DomainBusinessLogicException))] | ||
public void TryToUpdateUserWithRepeatedMailTest() | ||
{ | ||
User user = new User() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "Martin", | ||
LastName = "Gutman", | ||
UserName = "colo20", | ||
Mail = "[email protected]", | ||
Password = "martin1234" | ||
}; | ||
user.Name = "Gonzalo"; | ||
var userRepositoryMock = new Mock<IUserRepository>(MockBehavior.Strict); | ||
userRepositoryMock.Setup(m => m.Get(It.IsAny<Guid>())).Returns(user); | ||
userRepositoryMock.Setup(m => m.GetUserByEmail(It.IsAny<string>())).Returns(user); | ||
userRepositoryMock.Setup(m => m.Update(It.IsAny<User>())); | ||
var userLogic = new UserManagement(userRepositoryMock.Object); | ||
var result = userLogic.UpdateUser(user.Id, user); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ClientBusinessLogicException))] | ||
public void UpdateNotExistUser() | ||
|
@@ -616,6 +639,7 @@ public void UpdateNotExistUser() | |
user.Name = "Gonzalo"; | ||
var userRepositoryMock = new Mock<IUserRepository>(MockBehavior.Strict); | ||
userRepositoryMock.Setup(m => m.Get(It.IsAny<Guid>())).Throws(new ClientException()); | ||
userRepositoryMock.Setup(m => m.GetUserByEmail(It.IsAny<string>())).Returns(value: null); | ||
var userLogic = new UserManagement(userRepositoryMock.Object); | ||
var result = userLogic.UpdateUser(user.Id, user); | ||
} | ||
|
@@ -638,6 +662,7 @@ public void UpdateInvalidUserWithEmptyName() | |
user.Name = ""; | ||
var userRepositoryMock = new Mock<IUserRepository>(MockBehavior.Strict); | ||
userRepositoryMock.Setup(m => m.Get(It.IsAny<Guid>())).Returns(user); | ||
userRepositoryMock.Setup(m => m.GetUserByEmail(It.IsAny<string>())).Returns(value: null); | ||
var userLogic = new UserManagement(userRepositoryMock.Object); | ||
var result = userLogic.UpdateUser(user.Id, user); | ||
} | ||
|
@@ -659,6 +684,7 @@ public void UpdateUserInvalidDataBaseError() | |
user.Name = "Gonzalo"; | ||
var userRepositoryMock = new Mock<IUserRepository>(MockBehavior.Strict); | ||
userRepositoryMock.Setup(m => m.Get(It.IsAny<Guid>())).Returns(user); | ||
userRepositoryMock.Setup(m => m.GetUserByEmail(It.IsAny<string>())).Returns(value: null); | ||
userRepositoryMock.Setup(m => m.Update(It.IsAny<User>())).Throws(new ServerException()); | ||
var userLogic = new UserManagement(userRepositoryMock.Object); | ||
var result = userLogic.UpdateUser(user.Id, user); | ||
|
2 changes: 2 additions & 0 deletions
2
Uru_NaturalBooking/DataAccess/Migrations/20201123183539_ObligatorioMigrationV123_11_2020.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Uru_NaturalBooking/DataAccess/Migrations/20201124003332_ObligatorioMigrationV223_11_2020.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Uru_NaturalBooking/DataAccess/Migrations/20201124003927_ObligatorioMigrationV323_11_2020.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
Uru_NaturalBooking/WebApiTest/bin/Debug/netcoreapp3.1/FilesToImport/Lodgings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters