Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }