コード例 #1
0
        public void AutomaticallyReplaysEventsIfViewIsPurged(int numberOfCommands)
        {
            var allPotatoesView = new MongoDbViewManager <AllPotatoesView>(_mongoDatabase);

            _dispatcher.AddViewManager(allPotatoesView);

            Console.WriteLine("Processing {0} commands....", numberOfCommands);
            Enumerable.Range(0, numberOfCommands - 1)
            .ToList()
            .ForEach(i => _commandProcessor.ProcessCommand(new BitePotato("someid1", .01m)));

            var lastResult = _commandProcessor.ProcessCommand(new BitePotato("someid2", .01m));

            Console.WriteLine("Waiting until {0} has been dispatched to the view...", lastResult.GetNewPosition());
            allPotatoesView.WaitUntilProcessed(lastResult, TimeSpan.FromSeconds(2)).Wait();

            var viewOnFirstLoad = allPotatoesView.Load(GlobalInstanceLocator.GetViewInstanceId());

            Assert.That(viewOnFirstLoad, Is.Not.Null);

            Console.WriteLine("Purging the view!");
            allPotatoesView.Purge();

            Console.WriteLine("Waiting until {0} has been dispatched to the view...", lastResult.GetNewPosition());
            allPotatoesView.WaitUntilProcessed(lastResult, TimeSpan.FromSeconds(4)).Wait();

            var viewOnNextLoad = allPotatoesView.Load(GlobalInstanceLocator.GetViewInstanceId());

            Assert.That(viewOnNextLoad, Is.Not.Null);

            Assert.That(viewOnNextLoad.LastGlobalSequenceNumber, Is.EqualTo(viewOnFirstLoad.LastGlobalSequenceNumber));
        }
コード例 #2
0
        protected override void DoSetUp()
        {
            var servicePath = TestAzureHelper.GetPath("test");

            _commandProcessor = CommandProcessor.With()
                                .Logging(l => l.UseConsole(minLevel: Logger.Level.Debug))
                                .EventStore(e => e.Register <IEventStore>(c => new InMemoryEventStore()))
                                .EventDispatcher(e => e.UseAzureServiceBusRelayEventDispatcher("cirqus", servicePath, TestAzureHelper.KeyName, TestAzureHelper.SharedAccessKey))
                                .Create();

            RegisterForDisposal(_commandProcessor);

            _eventStoreProxy = new AzureServiceBusRelayEventStoreProxy("cirqus", servicePath, TestAzureHelper.KeyName, TestAzureHelper.SharedAccessKey);

            RegisterForDisposal(_eventStoreProxy);

            _viewManager = new InMemoryViewManager <View>();

            var serializer = new JsonDomainEventSerializer();
            var typeMapper = new DefaultDomainTypeNameMapper();

            var eventDispatcher = new ViewManagerEventDispatcher(new DefaultAggregateRootRepository(_eventStoreProxy, serializer, typeMapper), _eventStoreProxy, serializer, typeMapper);

            RegisterForDisposal(eventDispatcher);

            eventDispatcher.AddViewManager(_viewManager);
            eventDispatcher.Initialize();
        }
コード例 #3
0
ファイル: TestContext.cs プロジェクト: kaleyroy/Cirqus
        public TestContext AddViewManager(IViewManager viewManager)
        {
            if (_viewManagerEventDispatcher == null)
            {
                return(this);
            }

            _addedViews.Add(viewManager);
            _viewManagerEventDispatcher.AddViewManager(viewManager);

            return(this);
        }