public void execute_logs_any_error_raised_by_the_inner_action()
        {
            var waitHandle = new ManualResetEventSlim();
            var logger = new LoggerMock(MockBehavior.Loose);
            var loggerService = new LoggerServiceMock(MockBehavior.Loose);
            var action = new ActionMock(MockBehavior.Loose);

            logger
                .When(x => x.Log(LogLevel.Error, It.IsAny<string>()))
                .Do(waitHandle.Set);

            loggerService
                .When(x => x.GetLogger(It.IsAny<Type>()))
                .Return(logger);

            action
                .When(x => x.Execute(It.IsAny<ExecutionContext>()))
                .Return(Observable.Throw<Unit>(new InvalidOperationException("Something bad happened")));

            var sut = new DoNotAwaitActionBuilder()
                .WithLoggerService(loggerService)
                .WithInnerAction(action)
                .Build();

            sut.Execute(new ExecutionContext());

            Assert.True(waitHandle.Wait(TimeSpan.FromSeconds(3)));
        }
Beispiel #2
0
        public void execute_logs_any_error_raised_by_the_inner_action()
        {
            var waitHandle    = new ManualResetEventSlim();
            var logger        = new LoggerMock(MockBehavior.Loose);
            var loggerService = new LoggerServiceMock(MockBehavior.Loose);
            var action        = new ActionMock(MockBehavior.Loose);

            logger
            .When(x => x.Log(LogLevel.Error, It.IsAny <string>()))
            .Do(waitHandle.Set);

            loggerService
            .When(x => x.GetLogger(It.IsAny <Type>()))
            .Return(logger);

            action
            .When(x => x.Execute(It.IsAny <ExecutionContext>()))
            .Return(Observable.Throw <Unit>(new InvalidOperationException("Something bad happened")));

            var sut = new DoNotAwaitActionBuilder()
                      .WithLoggerService(loggerService)
                      .WithInnerAction(action)
                      .Build();

            sut.Execute(new ExecutionContext());

            Assert.True(waitHandle.Wait(TimeSpan.FromSeconds(3)));
        }
        public void execute_does_not_wait_for_inner_actions_execution_to_complete_before_itself_completing()
        {
            var action = new ActionMock();

            action
                .When(x => x.Execute(It.IsAny<ExecutionContext>()))
                .Return(Observable.Never<Unit>());

            var sut = new DoNotAwaitActionBuilder()
                .WithInnerAction(action)
                .Build();

            var completed = false;
            sut
                .Execute(new ExecutionContext())
                .Subscribe(_ => completed = true);

            Assert.True(completed);
        }
Beispiel #4
0
        public void execute_does_not_wait_for_inner_actions_execution_to_complete_before_itself_completing()
        {
            var action = new ActionMock();

            action
            .When(x => x.Execute(It.IsAny <ExecutionContext>()))
            .Return(Observable <Unit> .Never);

            var sut = new DoNotAwaitActionBuilder()
                      .WithInnerAction(action)
                      .Build();

            var completed = false;

            sut
            .Execute(new ExecutionContext())
            .Subscribe(_ => completed = true);

            Assert.True(completed);
        }