Beispiel #1
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();
        }
Beispiel #2
0
        protected static async Task <Guid> GivenExistingTicket(ApplicationDbContext db)
        {
            var command = new SubmitTicketCommand
            {
                Title          = $"Title - {Guid.NewGuid()}",
                Details        = $"Details - {Guid.NewGuid()}",
                SubmitterEmail = $"email{Guid.NewGuid()}@example.com",
                SubmitterName  = $"Test User {Guid.NewGuid()}"
            };

            var handler = new SubmitTicketHandler(db);

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

            return(result.TicketId);
        }