Example #1
0
        public async Task StatusChange()
        {
            var counter = 0;
            var action  = new VoidThingActionInformation();

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

            action.StatusChanged += OnStatusChange;

            await action.ExecuteAsync(Substitute.For <Thing>(), _provider);

            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(VoidThingActionInformation)
            });

            void OnStatusChange(object sender, EventArgs args)
            {
                ((ThingActionInformation)sender).Status.Should().Be((ActionStatus)counter++);
            }
        }
Example #2
0
        public void ExecuteWithThrow()
        {
            var action = new VoidThingActionInformation();

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

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

            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(VoidThingActionInformation)
            });
        }