public async Task GivenAnInexistentId_WhenDeleteAsync_ThenReturnFalse() { var ticket = TicketsFactory.ValidTicket(); var result = await _repository.DeleteAsync(ticket.Id); result.Should().BeFalse(); }
public async Task GivenAnInexistentId_WhenGetByIdAsync_ThenReturnNull() { var ticket = TicketsFactory.ValidTicket(); var result = await _repository.GetByIdAsync(ticket.Id); result.Should().BeNull(); }
public async Task GivenATicket_WhenCreateAsync_ThenReturnTicketEntity() { var ticket = TicketsFactory.ValidTicket(); var result = await _repository.CreateAsync(ticket); result.Should().BeOfType <Ticket>(); }
public async Task GivenAnId_WhenDeleteTicketByIdCommandHandler_ThenReturnTrue() { var ticket = TicketsFactory.ValidTicket(); var command = new DeleteTicketByIdCommand(ticket.Id); var mockRepo = new Mock <ITicketRepository>(); mockRepo.Setup(db => db.DeleteAsync(command.Id).Result).Returns(true); var handler = new DeleteTicketByIdCommandHandler(mockRepo.Object); var result = await handler.Handle(command, CancellationToken.None); result.Should().BeTrue(); }
public async Task GivenAList_WhenGetAllTicketsQueryHandler_ThenReturnNotNull() { var ticket1 = TicketsFactory.ValidTicket(); var ticket2 = TicketsFactory.ValidTicket(); var tickets = new List <Ticket> { ticket1, ticket2 }; var command = new GetAllTicketsQuery(); var mockRepo = new Mock <ITicketRepository>(); mockRepo.Setup(db => db.GetAllAsync().Result).Returns(tickets); var handler = new GetAllTicketsQueryHandler(mockRepo.Object); var result = await handler.Handle(command, CancellationToken.None); result.Should().NotContainNulls(); result.Should().HaveCount(tickets.Count); result.Should().Contain(ticket1); }