public async Task GetsCorrectTrack() { //лучше создать и добавить новый тикет var expected = await _context.Tickets.Select(t => new { t.Id, t.Track }) .FirstAsync(); var query = new TicketDetails() { Id = expected.Id }; var handler = new TicketDetailsHandler(_context, GetMapper()); var result = (await handler.Handle(query, new System.Threading.CancellationToken())) .Ticket .Entries; CollectionAssert.IsNotEmpty(result); Assert.AreEqual(expected.Track.Count(), result.Count()); CollectionAssert.AreEqual(expected.Track, result, new TrackComparer()); }
public async Task CanGetTicket() { var ticket = await _context.Tickets.FirstAsync(); var query = new TicketDetails() { Id = ticket.Id }; var handler = new TicketDetailsHandler(_context, GetMapper()); var result = await handler.Handle(query, new System.Threading.CancellationToken()); Assert.IsNotNull(result as TicketDetailsVm); }
public void Throws_onWrongIdn() { const int InvalidId = -1; string errorMsg = $"Entity \"Ticket\" ({InvalidId}) was not found."; var query = new TicketDetails() { Id = InvalidId }; var handler = new TicketDetailsHandler(_context, GetMapper()); var act = Assert.ThrowsAsync <NotFoundException>(async() => await handler.Handle(query, new System.Threading.CancellationToken())); StringAssert.AreEqualIgnoringCase(errorMsg, act.Message); }
public async Task GetsCorrectIssuer() { var expected = await _context.Tickets.Select(t => new { t.Id, t.Issuer }) .FirstAsync(); var query = new TicketDetails() { Id = expected.Id }; var handler = new TicketDetailsHandler(_context, GetMapper()); var result = await handler.Handle(query, new System.Threading.CancellationToken()); Assert.AreEqual(expected.Issuer.Id, result.Ticket.Issuer.Id); Assert.AreEqual(expected.Issuer.Name, result.Ticket.Issuer.Name); }
public async Task GetsCorrectDetails() { //лучше создать и добавить новый тикет var expected = await _context.Tickets.Select(t => new { t.Id, t.Issue, t.TicketStatus }) .FirstAsync(); var query = new TicketDetails() { Id = expected.Id }; var handler = new TicketDetailsHandler(_context, GetMapper()); var result = await handler.Handle(query, new System.Threading.CancellationToken()); Assert.AreEqual(expected.Id, result.Ticket.Id); Assert.AreEqual(expected.Issue, result.Ticket.Issue); Assert.AreEqual((int)expected.TicketStatus, result.Ticket.TicketStatus); }