Exemple #1
0
            public void SucceedingTaskShouldRaiseStartThenSuccessEvents()
            {
                using (var fixture = new SimpleContextFixture(
                           b => b.RegisterInstance(this.log).As <IExecutionLog>()))
                {
                    this.task.Execute(fixture.Context);
                }

                this.log.Received(1).TaskStarted(this.task);
                this.log.Received(1).TaskSucceeded(this.task);

                this.log.DidNotReceiveWithAnyArgs().TaskFailed(null, Arg.Any <string>());
            }
Exemple #2
0
            public void FailedTaskShouldRaiseStartThenFailedEvents()
            {
                this.task.ExecuteFunction =
                    c => { throw new InvalidOperationException(); };

                using (var fixture = new SimpleContextFixture(
                           b => b.RegisterInstance(this.log).As <IExecutionLog>()))
                {
                    try
                    {
                        this.task.Execute(fixture.Context);
                    }
                    catch (AggregateException)
                    {
                        // This exception type is thrown because we are executing in
                        // an asynchronous context.
                    }
                }

                this.log.Received(1).TaskStarted(this.task);
                this.log.Received(1).TaskFailed(this.task, Arg.Any <string>());

                this.log.DidNotReceiveWithAnyArgs().TaskSucceeded(null);
            }