示例#1
0
        private void before_each()
        {
            _node       = EmbeddedEventStore.Start();
            _connection = EmbeddedEventStoreConnection.Create(_node);
            _connection.ConnectAsync().Wait();

            _sut = new UserRegistrationProcessRepository(_connection, new EventSerializer());
        }
        private void before_each()
        {
            var node = EmbeddedEventStore.Start();

            var connectionSettings = ConnectionSettings
                                     .Create()
                                     .SetDefaultUserCredentials(new UserCredentials("admin", "changeit"));

            var connection = EmbeddedEventStoreConnection.Create(node, connectionSettings);

            connection.ConnectAsync().Wait();

            var eventSerializer = new EventSerializer();
            var userRegistrationProcessRepository = new UserRegistrationProcessRepository(connection, eventSerializer);
            var userByEmailInMemoryIndex          = new UserByEmailIndex(connection, eventSerializer);

            var commandService = new UserRegistrationCommandService(userRegistrationProcessRepository);
            var queryService   = new UserRegistrationQueryService(userRegistrationProcessRepository);

            var userRepository = new UserRepository(connection, eventSerializer);

            var userRegistrationEventHandler = new UserRegistrationEventHandler(
                userRegistrationProcessRepository,
                userRepository,
                userByEmailInMemoryIndex);

            var userRegistrationEventHandlerAdapter = new UserRegistrationEventHandlerAdapter(userRegistrationEventHandler);
            var subscriptionStarter = new EventStoreSubscriptionStarter(eventSerializer, userRegistrationEventHandlerAdapter);
            var subscription        = subscriptionStarter.Start(connection);

            _node           = node;
            _connection     = connection;
            _commandService = commandService;
            _queryService   = queryService;
            _subscription   = subscription;
        }