public void Executing_it_should_create_unit_of_work_with_factory()
        {
            var factoryMock = MockRepository.GenerateMock<IUnitOfWorkFactory>();
            var contextMock = MockRepository.GenerateMock<IUnitOfWorkContext>();

            factoryMock.Expect(t => t.CreateUnitOfWork()).Repeat.Once().Return(contextMock);

            Func<CreateMessageCommand, Message> creation = (c) => new Message(c.Text);
            var executor = new CreatingCommandExecutor<CreateMessageCommand, Message>(creation, factoryMock);

            var cmd = new CreateMessageCommand();
            executor.Execute(cmd);

            factoryMock.VerifyAllExpectations();
        }
        public void Executing_it_should_invoke_action()
        {
            var invoked = false;

            var factoryMock = MockRepository.GenerateMock<IUnitOfWorkFactory>();
            var contextMock = MockRepository.GenerateMock<IUnitOfWorkContext>();

            factoryMock.Stub(t => t.CreateUnitOfWork()).Return(contextMock);
            contextMock.Expect(t => t.Accept()).Repeat.Once();

            Func<CreateMessageCommand, Message> creation = (c) =>
            {
                invoked = true;
                return new Message(c.Text);
            };

            var executor = new CreatingCommandExecutor<CreateMessageCommand, Message>(creation, factoryMock);

            var cmd = new CreateMessageCommand();
            executor.Execute(cmd);

            invoked.Should().BeTrue();
        }