Skip to content

Commit

Permalink
fix: test pedido
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunobento1990 committed Feb 19, 2024
1 parent 7ffb626 commit 20c0c89
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,6 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

.env
12 changes: 11 additions & 1 deletion OpenAdm.Api/.env
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@

STRING_CONNECTION=User ID=userdbopemadm; Password=VMUEzSwBxepp; Host=opem-adm-db.ctma8dhskcgs.us-east-1.rds.amazonaws.com; Port=5432; Database=open-adm; Pooling=true;
URL_DISCORD=https://discord.com/api/webhooks/
DISCORD_WEB_HOOK_ID=1188793814220025936
DISCORD_WEB_HOOK_TOKEN=WUJ4efl9hv40RsTMX3isd35Hp8zOOoBRoRYY5-g1lbQnMG4A2rfdI04bQXo1ci2trJCV
AMBIENTE=develop
JWT_KEY=1a31ede4-1f1c-4d32-b4a6-b48788d0ff4c
JWT_ISSUE=https://api.open-adm.tech
JWT_AUDIENCE=OPENADMAUDIENCE
JWT_EXPIRATION=24
REDIS_URL=201.182.97.170:23647,password=SjK44193CxNH
MENSAGERIA_URI=amqp://openadmadmin:[email protected]:8412/homologacao
9 changes: 6 additions & 3 deletions OpenAdm.Test/Application/Test/PedidoServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ public async Task NaoDeveAlterarStatusPedidoJaEntregue()
var pedidoRepositoryMock = new Mock<IPedidoRepository>();
var tabelaDePrecoRepositoryMock = new Mock<ITabelaDePrecoRepository>();
var tokenServiceMock = new Mock<ITokenService>();
var processarPedidoServiceMock = new Mock<IProcessarPedidoService>();

pedidoRepositoryMock.Setup(x => x.GetPedidoByIdAsync(pedido.Id)).ReturnsAsync(pedido);

var pedidoService = new PedidoService(pedidoRepositoryMock.Object, tokenServiceMock.Object, tabelaDePrecoRepositoryMock.Object);
var pedidoService = new PedidoService(pedidoRepositoryMock.Object, tokenServiceMock.Object, tabelaDePrecoRepositoryMock.Object, processarPedidoServiceMock.Object);

await Assert
.ThrowsAnyAsync<ExceptionApi>(
Expand All @@ -41,10 +42,11 @@ public async Task DeveAlterarStatusPedido()
var pedidoRepositoryMock = new Mock<IPedidoRepository>();
var tabelaDePrecoRepositoryMock = new Mock<ITabelaDePrecoRepository>();
var tokenServiceMock = new Mock<ITokenService>();
var processarPedidoServiceMock = new Mock<IProcessarPedidoService>();

pedidoRepositoryMock.Setup(x => x.GetPedidoByIdAsync(pedido.Id)).ReturnsAsync(pedido);

var pedidoService = new PedidoService(pedidoRepositoryMock.Object, tokenServiceMock.Object, tabelaDePrecoRepositoryMock.Object);
var pedidoService = new PedidoService(pedidoRepositoryMock.Object, tokenServiceMock.Object, tabelaDePrecoRepositoryMock.Object, processarPedidoServiceMock.Object);
var pedidoViewModel = await pedidoService.UpdateStatusPedidoAsync(pedidoUpdateStatus);

Assert.NotNull(pedidoViewModel);
Expand All @@ -61,11 +63,12 @@ public async Task DeveExcluirPedido()
var pedidoRepositoryMock = new Mock<IPedidoRepository>();
var tabelaDePrecoRepositoryMock = new Mock<ITabelaDePrecoRepository>();
var tokenServiceMock = new Mock<ITokenService>();
var processarPedidoServiceMock = new Mock<IProcessarPedidoService>();

pedidoRepositoryMock.Setup(x => x.GetPedidoByIdAsync(pedido.Id)).ReturnsAsync(pedido);
pedidoRepositoryMock.Setup(x => x.DeleteAsync(pedido)).ReturnsAsync(true);

var pedidoService = new PedidoService(pedidoRepositoryMock.Object, tokenServiceMock.Object, tabelaDePrecoRepositoryMock.Object);
var pedidoService = new PedidoService(pedidoRepositoryMock.Object, tokenServiceMock.Object, tabelaDePrecoRepositoryMock.Object, processarPedidoServiceMock.Object);
var result = await pedidoService.DeletePedidoAsync(pedido.Id);

Assert.IsType<bool>(result);
Expand Down

0 comments on commit 20c0c89

Please sign in to comment.