-
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.
Merge pull request #6 from WesleyJoseSantos/release
Release
- Loading branch information
Showing
26 changed files
with
447 additions
and
75 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Data; | ||
|
||
namespace UsersDBApi.Domain.Database | ||
{ | ||
public interface IConnection | ||
{ | ||
IDbConnection Get(string name); | ||
} | ||
} |
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
File renamed without changes.
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
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
File renamed without changes.
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UsersDBApi.Domain.DTOs; | ||
using UsersDBApi.Infra.Database.Models; | ||
|
||
namespace UsersDBApiTests.Infra.Database.Models | ||
{ | ||
[TestClass] | ||
public class UserModelTests | ||
{ | ||
[TestMethod] | ||
public void CreateMustReturnUserModel() | ||
{ | ||
var user = new UserDTO("username", "[email protected]", "3799034578", "userpass", UserLevel.Administrator); | ||
|
||
var result = UserModel.Create(user); | ||
|
||
Assert.AreEqual(user.Name, result.Name); | ||
Assert.AreEqual(user.Email, result.Email); | ||
Assert.AreEqual(user.Phone, result.Phone); | ||
Assert.AreEqual(user.Password, result.Password); | ||
Assert.AreEqual(user.Level, result.Level); | ||
} | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
UsersDBApiTests/Infra/Repositories/UsersRepositoryTests.cs
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using UsersDBApi.Infra.Usecases; | ||
using UsersDBApi.Domain.DTOs; | ||
using UsersDBApi.Domain.Errors; | ||
using UsersDBApi.Infra.Usecases.Users; | ||
using UsersDBApiTests.Mocks; | ||
|
||
namespace UsersDBApiTests.Infra.Usecases | ||
{ | ||
[TestClass] | ||
public class CreateUserTests | ||
{ | ||
[TestMethod] | ||
public void MustReturnInvalidNameError() | ||
{ | ||
// Arrange | ||
var repository = new UsersRepositoryMock(); | ||
var usecase = new CreateUser(repository); | ||
var result = usecase.Handle(MockedData.UserInvalidName); | ||
|
||
Assert.IsTrue(result.IsLeft); | ||
Assert.IsTrue(result.LeftOrDefault() is InvalidNameError); | ||
} | ||
|
||
[TestMethod] | ||
public void MustReturnInvalidEmailError() | ||
{ | ||
var repository = new UsersRepositoryMock(); | ||
var usecase = new CreateUser(repository); | ||
var result = usecase.Handle(MockedData.UserInvalidEmail); | ||
|
||
Assert.IsTrue(result.IsLeft); | ||
Assert.IsTrue(result.LeftOrDefault() is InvalidEmailError); | ||
} | ||
|
||
[TestMethod] | ||
public void MustReturnInvalidPhoneNumber() | ||
{ | ||
var repository = new UsersRepositoryMock(); | ||
var usecase = new CreateUser(repository); | ||
var result = usecase.Handle(MockedData.UserInvalidPhone); | ||
|
||
Assert.IsTrue(result.IsLeft); | ||
Assert.IsTrue(result.LeftOrDefault() is InvalidPhoneNumberError); | ||
} | ||
|
||
[TestMethod] | ||
public void MustReturnInvalidPasswordError() | ||
{ | ||
var repository = new UsersRepositoryMock(); | ||
var usecase = new CreateUser(repository); | ||
var result = usecase.Handle(MockedData.UserInvalidPassword); | ||
|
||
Assert.IsTrue(result.IsLeft); | ||
Assert.IsTrue(result.LeftOrDefault() is InvalidPasswordError); | ||
} | ||
|
||
[TestMethod] | ||
public void MustReturnCreatedUser() | ||
{ | ||
var repository = new UsersRepositoryMock(); | ||
var usecase = new CreateUser(repository); | ||
var result = usecase.Handle(MockedData.NewUser); | ||
|
||
Assert.IsTrue(result.IsRight); | ||
Assert.AreEqual(result.RightOrDefault().Name, MockedData.NewUser.Name); | ||
Assert.AreEqual(result.RightOrDefault().Email, MockedData.NewUser.Email); | ||
Assert.AreEqual(result.RightOrDefault().Phone, MockedData.NewUser.Phone); | ||
Assert.AreEqual(result.RightOrDefault().Password, MockedData.NewUser.Password); | ||
Assert.AreEqual(result.RightOrDefault().Level, MockedData.NewUser.Level); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UsersDBApi.Infra.Usecases.Users; | ||
using UsersDBApiTests.Mocks; | ||
|
||
namespace UsersDBApiTests.Infra.Usecases | ||
{ | ||
[TestClass] | ||
public class GetAllUsersTests | ||
{ | ||
[TestMethod] | ||
public void MustReturnAllUsers() | ||
{ | ||
var repository = new UsersRepositoryMock(); | ||
var usecase = new GetAllUsers(repository); | ||
var result = usecase.Handle(); | ||
var users = result.RightOrDefault(); | ||
|
||
Assert.IsTrue(result.IsRight); | ||
|
||
int i = 0; | ||
foreach (var user in users) | ||
{ | ||
Assert.AreEqual(MockedData.Users[i].Name, user.Name); | ||
Assert.AreEqual(MockedData.Users[i].Email, user.Email); | ||
Assert.AreEqual(MockedData.Users[i].Phone, user.Phone); | ||
Assert.AreEqual(MockedData.Users[i].Password, user.Password); | ||
Assert.AreEqual(MockedData.Users[i].Level, user.Level); | ||
i++; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.