示例#1
0
        public async Task GetExistingVariablesShouldSucceed()
        {
            // Arrange
            var ticket = new Ticket()
            {
                Id = Guid.NewGuid()
                     .ToString(),
                OwnerIdentity    = "*****@*****.**",
                CustomerIdentity = "*****@*****.**"
            };

            HelpDeskExtension.GetCustomerActiveTicketAsync(UserIdentity, CancellationToken).Returns(ticket);
            var target = GetTarget();

            // Act
            var actualTicketId = await target.GetVariableAsync("id", Context, CancellationToken);

            var actualOwnerIdentity = await target.GetVariableAsync("ownerIdentity", Context, CancellationToken);

            var actualCustomerIdentity = await target.GetVariableAsync("customerIdentity", Context, CancellationToken);

            // Assert
            actualTicketId.ShouldBe(ticket.Id);
            actualOwnerIdentity.ShouldBe(ticket.OwnerIdentity);
            actualCustomerIdentity.ShouldBe(ticket.CustomerIdentity);
        }
示例#2
0
        public async Task ExecuteShouldCallExtension()
        {
            // Arrange
            var target = GetTarget();

            // Act
            await target.ExecuteAsync(Context, Settings, CancellationToken);

            // Assert
            HelpDeskExtension.Received(1)
            .CreateTicketAsync(Arg.Is <Ticket>(t => t.CustomerIdentity == UserIdentity && t.OwnerIdentity == OwnerIdentity), CancellationToken);
        }
示例#3
0
        public async Task GetWithNoTicketShouldReturnNull()
        {
            // Arrange
            Ticket ticket = null;

            HelpDeskExtension.GetCustomerActiveTicketAsync(UserIdentity, CancellationToken)
            .Throws(new LimeException(ReasonCodes.COMMAND_RESOURCE_NOT_FOUND, "Not found"));
            var target = GetTarget();

            // Act
            var actual = await target.GetVariableAsync("id", Context, CancellationToken);

            // Assert
            actual.ShouldBeNull();
        }
示例#4
0
        public async Task GetNullPropertyShouldReturnNull()
        {
            // Arrange
            var ticket = new Ticket()
            {
                Id = null
            };

            HelpDeskExtension.GetCustomerActiveTicketAsync(UserIdentity, CancellationToken).Returns(ticket);
            var target = GetTarget();

            // Act
            var actual = await target.GetVariableAsync("id", Context, CancellationToken);

            // Assert
            actual.ShouldBeNull();
        }
示例#5
0
        public async Task GetNonExistingPropertyShouldReturnNull()
        {
            // Arrange
            var ticket = new Ticket()
            {
                Id = Guid.NewGuid()
                     .ToString(),
                OwnerIdentity    = "*****@*****.**",
                CustomerIdentity = "*****@*****.**"
            };

            HelpDeskExtension.GetCustomerActiveTicketAsync(UserIdentity, CancellationToken).Returns(ticket);
            var target = GetTarget();

            // Act
            var actual = await target.GetVariableAsync("doesNotExists", Context, CancellationToken);

            // Assert
            actual.ShouldBeNull();
        }
示例#6
0
        public async Task ExecuteWithVariableShouldSetOnContext()
        {
            // Arrange
            var ticketId = Guid.NewGuid().ToString();
            var ticket   = new Ticket()
            {
                Id = ticketId
            };

            Settings.Variable = "myTicketId";
            HelpDeskExtension.CreateTicketAsync(Arg.Any <Ticket>(), Arg.Any <CancellationToken>()).Returns(ticket);
            var target = GetTarget();

            // Act
            await target.ExecuteAsync(Context, Settings, CancellationToken);

            // Assert
            HelpDeskExtension.Received(1)
            .CreateTicketAsync(Arg.Is <Ticket>(t => t.CustomerIdentity == UserIdentity && t.OwnerIdentity == OwnerIdentity), CancellationToken);
            Context.SetVariableAsync(Settings.Variable, ticketId, CancellationToken, default);
        }