Exemple #1
0
        public void DeleteTest()
        {
            //Arrange
            List <Ticket> tickets = new List <Ticket>();
            var           ticket1 = new Ticket()
            {
                Id = 1, Price = 400, FlightId = 1
            };
            var ticket2 = new Ticket()
            {
                Id = 2, Price = 200, FlightId = 2
            };

            tickets.Add(ticket1);
            tickets.Add(ticket2);

            //Act
            ticketMockRepository.Setup(x => x.GetAll()).Returns(tickets);
            ticketMockRepository.Setup(x => x.Delete(ticket1.Id.ToString()));
            mapper.Setup(x => x.Map <Ticket>(ticket1)).Returns(ticket1);

            ticketService.Delete(ticket1.Id);


            //Assert
            Assert.Null(ticketService.Get(ticket1.Id));
        }
 public IActionResult DeleteTicket(int id)
 {
     _ticketService.Delete(id);
     return(RedirectToAction("GetAllTickets", "Admin"));
 }