public void WhenIIssueACreateElectionCommand()
        {
            //setup the "bus" components
            m_commandDispatcher = new CommandDispatcher();
            m_eventPublisher = new EventDispatcher();

            //register the command handler
            var repository = MockRepository.GenerateStub<IRepository<Election>>();
            m_commandDispatcher.Register(new MakeAnElectionCommandHandler(repository, null));

            //register the event handler
            m_eventPublisher.RegisterHandler<ElectionMadeEvent>(@event => m_electionCreatedEvent = @event);

            //wire-up the domain event to the event publisher
            DomainEvents.Register<ElectionMadeEvent>(@event => m_eventPublisher.Publish(@event));

            //create and send the command
            var command = new MakeAnElection
                              {
                                  AdministratorCode = "AdmCode",
                                  CompanyCode = "CoCode",
                                  ParticipantId = "12345",
                                  ElectionAmount = 1000,
                                  ElectionReason = "election reason",
                              };

            m_commandDispatcher.Dispatch<MakeAnElection>(command);
            
            Assert.Pass();
        }
        public void WhenIIssueACreateElectionCommand()
        {
            //setup the "bus" components
            m_commandDispatcher = new CommandDispatcher();
            m_eventPublisher    = new EventDispatcher();

            //register the command handler
            var repository = MockRepository.GenerateStub <IRepository <Election> >();

            m_commandDispatcher.Register(new MakeAnElectionCommandHandler(repository, null));

            //register the event handler
            m_eventPublisher.RegisterHandler <ElectionMadeEvent>(@event => m_electionCreatedEvent = @event);

            //wire-up the domain event to the event publisher
            DomainEvents.Register <ElectionMadeEvent>(@event => m_eventPublisher.Publish(@event));

            //create and send the command
            var command = new MakeAnElection
            {
                AdministratorCode = "AdmCode",
                CompanyCode       = "CoCode",
                ParticipantId     = "12345",
                ElectionAmount    = 1000,
                ElectionReason    = "election reason",
            };

            m_commandDispatcher.Dispatch <MakeAnElection>(command);

            Assert.Pass();
        }
        public static ICommandDispatcher RegisterFileSystemObjectStore(this ICommandDispatcher commandDispatcherMock, ITime timeMock, IFileObjectStoreConfig config, IFileSystem fileSystem)
        {
            commandDispatcherMock
            .Register(new FileSystemListObjectKeysCommandHandler(config, fileSystem))
            .Register(new FileSystemRetrieveObjectCommandHandler(config))
            .Register(new FileSystemStoreObjectCommandHandler(config, timeMock));

            return(commandDispatcherMock);
        }
        public static ICommandDispatcher RegisterMemoryObjectStore(this ICommandDispatcher commandDispatcherMock, ITime timeMock)
        {
            var memoryObjectStoreData = new MemoryObjectStore();

            commandDispatcherMock
            .Register(new MemoryListObjectKeysCommandHandler(memoryObjectStoreData))
            .Register(new MemoryRetrieveObjectCommandHandler(memoryObjectStoreData))
            .Register(new MemoryStoreObjectCommandHandler(timeMock, memoryObjectStoreData));

            return(commandDispatcherMock);
        }
        public static ICommandDispatcher RegisterReducerFunc(this ICommandDispatcher commandDispatcherMock, IReducerFunc reducerFunc)
        {
            var serviceProviderMock = Substitute.For <IServiceProvider>();

            serviceProviderMock.GetService(Arg.Any <Type>())
            .Returns(reducerFunc);

            commandDispatcherMock
            .Register(new ReducerFuncHandler(Substitute.For <IConfig>(), serviceProviderMock));

            return(commandDispatcherMock);
        }
 public void RegisterCommands()
 {
     //_commands.Register("Pessoas.Novo", new ModuleCommand<bool>(PessoasFacade.Novo));
     _commands.Register("Clients.GetClientList", new ModuleCommand <DataTable>(ClientsCommandFacade.GetClientList));
     //_commands.Register("Pessoas.RecuperarPessoaNome", new ModuleCommand<string, string>(PessoasFacade.RecuperarPessoaNome));
 }
Exemple #7
0
        public void RegisterCommand(string name, CommandCreater creater)
        {
            RegisterObserver(name, ExecuteCommand);

            commandDispatcher.Register(name, creater);
        }