private void describe_Start()
        {
            context["when event has been added to EventStore"] = () =>
            {
                before = () =>
                {
                    var someEvent = new DummyEvent();
                    var eventData = _serializer.ToEventData(someEvent);
                    _connection.AppendToStreamAsync("dummy", ExpectedVersion.Any, eventData).Wait();

                    _subscription = _sut.Start(_connection);
                };

                after = () => _subscription?.Stop();

                it["eventually calls event handler"] =
                    () => Eventually.IsTrue(() => _eventHandler.WasCalledWithDummyEvent);
            };
        }
コード例 #2
0
        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;
        }