Пример #1
0
        public async Task CanGetTickets()
        {
            var user = await _context.Users.FirstAsync();

            var expectedCount = user.Tickets.Count;

            var command = GetCommand(user.Id.ToString());

            var handler = GetHandler(_context, _identityServiceFactory.Create());

            var result = await handler.Handle(command, new CancellationToken());

            CollectionAssert.IsNotEmpty(result.Tickets);
            Assert.AreEqual(expectedCount, result.Tickets.Count());
        }
        public async Task CreateTicket_can_Create()
        {
            var userService = _userServiceFactory.Create();
            var handler     = GetHandler(userService);

            int ticketCount = await _context.Tickets.CountAsync();

            var user = await _context.Users.FirstAsync();

            var command = GetCommand(It.IsAny <string>(), GetUserIdentity(user));

            var result = await handler.Handle(command, new CancellationToken());

            Assert.IsNotNull(await _context.Tickets.FindAsync(result));
            Assert.AreEqual(ticketCount + 1, await _context.Tickets.CountAsync());
        }
Пример #3
0
        public async Task CanAddMessage()
        {
            var ticket = await _context.Tickets.FirstAsync();

            const string expected = "test message";
            var          user     = ticket.Issuer;

            var userService = _userServiceFactory.Create();

            var command = new AddMessage {
                TicketId = ticket.Id, Content = expected, UserId = user.Id.ToString()
            };

            await GetHandler(_context, userService).Handle(command, new CancellationToken());

            var actual = (await _context.Tickets.FindAsync(ticket.Id)).Track.SingleOrDefault(t => t.Content == expected);

            //can assert.notnull
            StringAssert.AreEqualIgnoringCase(expected, actual.Content);
        }