예제 #1
0
        public async Task ExecuteAsync()
        {
            var action = new LongRunningThingActionInformation();

            action.GetId().Should().NotBeEmpty();
            action.TimeCompleted.Should().BeNull();
            action.Status.Should().Be(ActionStatus.Created);
            action.GetActionName().Should().Be("long-running-action");

            var task = action.ExecuteAsync(Substitute.For <Thing>(), _provider);

            action.Logs.Should().BeEmpty();

            action.TimeCompleted.Should().BeNull();
            action.Status.Should().Be(ActionStatus.Pending);

            await task;

            action.TimeCompleted.Should().NotBeNull();
            action.Status.Should().Be(ActionStatus.Completed);

            action.Logs.Should().NotBeEmpty();
            action.Logs.Should().HaveCount(1);
            action.Logs.Should().BeEquivalentTo(new List <string>
            {
                nameof(LongRunningThingActionInformation)
            });
        }
예제 #2
0
        public async Task Cancel()
        {
            var action = new LongRunningThingActionInformation();

            action.GetId().Should().NotBeEmpty();
            action.TimeCompleted.Should().BeNull();
            action.Status.Should().Be(ActionStatus.Created);
            action.GetActionName().Should().Be("long-running-action");

            var task = action.ExecuteAsync(Substitute.For <Thing>(), _provider);

            action.Logs.Should().BeEmpty();

            action.TimeCompleted.Should().BeNull();
            action.Status.Should().Be(ActionStatus.Pending);

            action.Cancel();

            await Task.Delay(200);

            action.TimeCompleted.Should().NotBeNull();
            action.Status.Should().Be(ActionStatus.Completed);

            action.Logs.Should().BeEmpty();
        }