This repository has been archived by the owner on Apr 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #93 from g12-4soat/feature/refactoring-testes
Refatoração dos testes já existentes
- Loading branch information
Showing
14 changed files
with
499 additions
and
530 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
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
50 changes: 0 additions & 50 deletions
50
test/TechLanches.UnitTests/Domain/PagamentoAggregateTest.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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using TechLanches.Domain.Aggregates; | ||
|
||
namespace TechLanches.UnitTests.Domain | ||
{ | ||
[Trait("Domain", "Pagamento")] | ||
public class PagamentoTest | ||
{ | ||
[Fact(DisplayName = "Criar pagamento com sucesso")] | ||
public void CriarPagamento_DeveRetornarSucesso() | ||
{ | ||
//Arrange | ||
var pedidoId = 1; | ||
var valor = 100; | ||
|
||
//Act | ||
var pagamento = new Pagamento(pedidoId, valor, FormaPagamento.QrCodeMercadoPago); | ||
|
||
//Assert | ||
Assert.NotNull(pagamento); | ||
Assert.Equal(pedidoId, pagamento.PedidoId); | ||
Assert.Equal(valor, pagamento.Valor); | ||
Assert.Equal(FormaPagamento.QrCodeMercadoPago, pagamento.FormaPagamento); | ||
Assert.Equal(StatusPagamento.Aguardando, pagamento.StatusPagamento); | ||
} | ||
|
||
[Theory(DisplayName = "Criar pagamento com falha")] | ||
[InlineData(0, 100)] | ||
[InlineData(1, 0)] | ||
public void CriarPagamento_Invalido_DeveLancarException(int pedidoId, decimal valor) | ||
{ | ||
//Arrange, Act & Assert | ||
Assert.Throws<DomainException>(() => new Pagamento(pedidoId, valor, FormaPagamento.QrCodeMercadoPago)); | ||
} | ||
|
||
[Fact(DisplayName = "Reprovar pagamento com status aprovado com falha")] | ||
public void Reprovar_PagamentoAprovado_DeveLancarException() | ||
{ | ||
//Arrange | ||
var pedidoId = 1; | ||
var valor = 100; | ||
var pagamentoId = 1; | ||
var pagamento = new Pagamento(pagamentoId, pedidoId, valor, StatusPagamento.Aprovado); | ||
|
||
//Act, Assert | ||
Assert.Throws<DomainException>(() => pagamento.Reprovar()); | ||
} | ||
|
||
[Fact(DisplayName = "Aprovar pagamento com sucesso")] | ||
public void Reprovar_PagamentoAguardando_DeveReprovarComSucesso() | ||
{ | ||
//Arrange | ||
var pedidoId = 1; | ||
var valor = 100; | ||
var pagamento = new Pagamento(pedidoId, valor, FormaPagamento.QrCodeMercadoPago); | ||
|
||
//Act | ||
pagamento.Reprovar(); | ||
|
||
//Act, Assert | ||
Assert.Equal(StatusPagamento.Reprovado, pagamento.StatusPagamento); | ||
} | ||
|
||
[Fact(DisplayName = "Aprovar pagamento com sucesso")] | ||
public void Aprovar_PagamentoAguardando_DeveAprovarComSucesso() | ||
{ | ||
//Arrange | ||
var pedidoId = 1; | ||
var valor = 100; | ||
var pagamento = new Pagamento(pedidoId, valor, FormaPagamento.QrCodeMercadoPago); | ||
|
||
//Act | ||
pagamento.Aprovar(); | ||
|
||
//Act, Assert | ||
Assert.Equal(StatusPagamento.Aprovado, pagamento.StatusPagamento); | ||
} | ||
} | ||
} |
Oops, something went wrong.