Exemple #1
0
        public void CreateTicketResponseCommand_WithoutAnyInput_ShouldThrowValidationException()
        {
            var command = new CreateTicketResponseCommand();

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
Exemple #2
0
        public async Task CreateTicketResponseCommand_WithoutConversationId_ShouldThrowValidationException()
        {
            var defaultUserId = await RunAsDefaultUserAsync();

            var command = new CreateTicketResponseCommand
            {
                Message = "Test"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
Exemple #3
0
        public async Task CreateTicketResponseCommand_WithoutMessage_ShouldThrowValidationException()
        {
            var createdTicketId = await SeedSampleTicket();

            var command = new CreateTicketResponseCommand
            {
                ConversationId = createdTicketId
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
Exemple #4
0
        public void CreateTicketResponseCommand_WithInvalidConversationId_ShouldThrowNotFoundException()
        {
            var invalidConversationId = new Guid("ef1dc766-98f5-424f-ad4c-0fb42a690140");

            var command = new CreateTicketResponseCommand
            {
                ConversationId = invalidConversationId,
                Message        = "Test"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
Exemple #5
0
        public async Task CreateTicketResponseCommand_ForClosedTicket_ShouldThrowException()
        {
            var createdTicketId = await SeedSampleTicket(true);

            var command = new CreateTicketResponseCommand
            {
                ConversationId = createdTicketId,
                Message        = "Test"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <Exception>().Which.Message.Should().Be("You can't reply to closed ticket");
        }
Exemple #6
0
        public async Task CreateTicketResponseCommand_WithDifferentUserThanAdmin_ShouldThrowForbiddenAccessException()
        {
            var createdTicketId = await SeedSampleTicket();

            await RunAsAdministratorAsync();

            var command = new CreateTicketResponseCommand
            {
                ConversationId = createdTicketId,
                Message        = "Test"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ForbiddenAccessException>();
        }
Exemple #7
0
        public async Task CreateTicketRepsonseCommand_WithValidInput_ShouldInsertTicketMessageAndReturnTicketMessageId()
        {
            var createdTicketId = await SeedSampleTicket();

            var command = new CreateTicketResponseCommand
            {
                ConversationId = createdTicketId,
                Message        = "Second Response"
            };

            var ticketMessageId = await SendAsync(command);

            var ticketMessage = await FindAsync <ConversationMessage>(ticketMessageId);

            ticketMessage.Should().NotBeNull();
            ticketMessage.Message.Should().Be("Second Response");
            ticketMessage.Id.Should().Be(ticketMessageId);
        }