コード例 #1
0
        public async Task Customer_update_adds_comment()
        {
            var db = MakeDbContext(nameof(Customer_update_adds_comment));
            var existingTicketId = await GivenExistingTicket(db);

            var updateCommand = new TicketCustomerUpdateCommand
            {
                Id          = existingTicketId,
                Comment     = $"Some New Comment {Guid.NewGuid()}",
                SubmitterId = $"test{Guid.NewGuid()}@example.com"
            };
            var handler = new TicketUpdateHandler(db);
            await handler.Handle(updateCommand, CancellationToken.None);

            var detailHandler  = new TicketDetailsHandler(db);
            var detailsRequest = new TicketDetailsRequest
            {
                Id = existingTicketId
            };
            var ticket = await detailHandler.Handle(detailsRequest, CancellationToken.None);

            ticket.Comments.Count.Should().Be(1);
            ticket.Comments[0].Text.Should().Be(updateCommand.Comment);
            ticket.Comments[0].SubmitterId.Should().Be(updateCommand.SubmitterId);
            ticket.Comments[0].DateEntered.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(5));
        }
コード例 #2
0
        public async Task Create_Details_RoundTrip()
        {
            var command = new SubmitTicketCommand
            {
                Title          = $"Title - {Guid.NewGuid()}",
                Details        = $"Details - {Guid.NewGuid()}",
                SubmitterEmail = $"email{Guid.NewGuid()}@example.com",
                SubmitterName  = $"Test User {Guid.NewGuid()}"
            };

            var dbContext = MakeDbContext(nameof(Create_Details_RoundTrip));

            var handler = new SubmitTicketHandler(dbContext);

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

            result.TicketId.Should().NotBeEmpty();

            var detailHandler  = new TicketDetailsHandler(dbContext);
            var detailsRequest = new TicketDetailsRequest
            {
                Id = result.TicketId
            };
            var ticket = await detailHandler.Handle(detailsRequest, CancellationToken.None);

            ticket.Should().NotBeNull();
            ticket.Should().BeEquivalentTo(command);
            ticket.Status.Should().Be(TicketStatus.New);
            ticket.DateSubmitted.Should().BeCloseTo(DateTime.UtcNow, 2000);
            ticket.DateClosed.Should().BeNull();
        }
コード例 #3
0
        public async Task <IActionResult> Details(Guid id, CancellationToken cancellationToken)
        {
            var request = new TicketDetailsRequest
            {
                Id = id
            };

            var ticket = await _mediator.Send(request, cancellationToken);

            if (ticket == null)
            {
                return(NotFound());
            }

            var viewModel = new TicketDetailsViewModel(ticket);

            return(View(viewModel));
        }