public UserRegistrationEventHandlerAdapter(
            UserRegistrationEventHandler userRegistrationEventHandler)
        {
            if (userRegistrationEventHandler == null)
            {
                throw new ArgumentNullException(nameof(userRegistrationEventHandler));
            }

            _userRegistrationEventHandler = userRegistrationEventHandler;
        }
Esempio n. 2
0
        private void before_each()
        {
            var userByEmailIndexStub = new UserByEmailIndexStub();

            var fakeEventStore = new FakeEventStore();
            var fakeUserRegistrationProcessRepository = new FakeUserRegistrationProcessRepository(fakeEventStore);
            var fakeUserRepository = new FakeUserRepository(fakeEventStore);

            _sut = new UserRegistrationEventHandler(
                fakeUserRegistrationProcessRepository,
                fakeUserRepository,
                userByEmailIndexStub);

            _userRegistrationProcessRepository = fakeUserRegistrationProcessRepository;
            _eventStore       = fakeEventStore;
            _userByEmailIndex = userByEmailIndexStub;
        }
        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;
        }