public void When_creating_with_creation_callback_the_callback_should_be_called_for_TransactionScope_creation()
        {
            var callCount = 0;
            var creationCallback = new Func<TransactionScope>(() =>
            {
                callCount++;
                return new TransactionScope();
            });

            var aExecutor = MockRepository.GenerateMock<ICommandExecutor<DummyCommand>>();
            var theWrapper = new TransactionalCommandExecutorWrapper<DummyCommand>(aExecutor, creationCallback);

            theWrapper.Execute(new DummyCommand());
            callCount.Should().Be(1);

            theWrapper.Execute(new DummyCommand());
            callCount.Should().Be(2);
        }
        public void When_creating_with_creation_callback_the_callback_should_be_called_for_TransactionScope_creation()
        {
            var callCount        = 0;
            var creationCallback = new Func <TransactionScope>(() =>
            {
                callCount++;
                return(new TransactionScope());
            });

            var aExecutor  = MockRepository.GenerateMock <ICommandExecutor <DummyCommand> >();
            var theWrapper = new TransactionalCommandExecutorWrapper <DummyCommand>(aExecutor, creationCallback);

            theWrapper.Execute(new DummyCommand());
            callCount.Should().Be(1);

            theWrapper.Execute(new DummyCommand());
            callCount.Should().Be(2);
        }
        public void When_executing_it_it_should_call_the_executor_given_via_ctor()
        {
            var theCommand = new DummyCommand();
            var theExecutor = MockRepository.GenerateMock<ICommandExecutor<DummyCommand>>();
            var theWrapper = new TransactionalCommandExecutorWrapper<DummyCommand>(theExecutor);

            theWrapper.Execute(theCommand);

            theExecutor.AssertWasCalled((e) => e.Execute(theCommand));
        }
        public void When_executing_it_it_should_call_the_executor_given_via_ctor()
        {
            var theCommand  = new DummyCommand();
            var theExecutor = MockRepository.GenerateMock <ICommandExecutor <DummyCommand> >();
            var theWrapper  = new TransactionalCommandExecutorWrapper <DummyCommand>(theExecutor);

            theWrapper.Execute(theCommand);

            theExecutor.AssertWasCalled((e) => e.Execute(theCommand));
        }
        public void Executing_a_command_with_it_should_call_the_executor_that_was_set_at_construct()
        {
            var aExecutor = MockRepository.GenerateMock<ICommandExecutor<ICommand>>();

            var aCommand = MockRepository.GenerateMock<ICommand>();
            var theWrapper = new TransactionalCommandExecutorWrapper<ICommand>(aExecutor);

            theWrapper.Execute(aCommand);

            aExecutor.AssertWasCalled(e=>e.Execute(aCommand));
        }
        public void Executing_a_command_with_it_should_call_the_executor_that_was_set_at_construct()
        {
            var aExecutor = MockRepository.GenerateMock <ICommandExecutor <ICommand> >();

            var aCommand   = MockRepository.GenerateMock <ICommand>();
            var theWrapper = new TransactionalCommandExecutorWrapper <ICommand>(aExecutor);

            theWrapper.Execute(aCommand);

            aExecutor.AssertWasCalled(e => e.Execute(aCommand));
        }