public void verify_can_scan_all_domain_events() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); Assert.That(sut.TotalEventCount, Is.GreaterThan(0)); }
public void verify_event_handled_by_base_projection() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); sut.InspectProjectionForEvents(typeof(TestProjectionInherited)); Assert.That(sut.EventHandled, Is.EquivalentTo(new[] { typeof(SampleAggregateCreated), typeof(SampleAggregateTouched) })); }
public void verify_inherited_event_handling() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); sut.InspectProjectionForEvents(typeof(TestProjectionBaseEvent)); Assert.That(sut.EventHandled, Is.EquivalentTo(new[] { typeof(SampleAggregateBaseEvent), typeof(SampleAggregateDerived1), typeof(SampleAggregateDerived2) })); }
public void verify_get_basic_event_handled_even_if_no_interface_is_declared() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); sut.InspectProjectionForEvents(typeof(TestProjectionWithoutInterface)); Assert.That(sut.EventHandled, Is.EquivalentTo(new[] { typeof(SampleAggregateCreated) })); }
public void verify_get_basic_event_handled() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); sut.InspectProjectionForEvents(typeof(Projection)); Assert.That(sut.EventHandled, Is.EquivalentTo(new[] { typeof(SampleAggregateCreated) })); }
public void verify_catch_all_projection() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); sut.InspectProjectionForEvents(typeof(TestProjectionCatchAll)); Assert.That(sut.EventHandled, Has.Count.EqualTo(sut.TotalEventCount)); }
public virtual void TestFixtureSetUp() { _eventStoreConnectionString = ConfigurationManager.ConnectionStrings["eventstore"].ConnectionString; var url = new MongoUrl(_eventStoreConnectionString); var client = new MongoClient(url); _db = client.GetDatabase(url.DatabaseName); _db.Drop(); ProjectionEngineConfig config = new ProjectionEngineConfig(); config.EventStoreConnectionString = _eventStoreConnectionString; config.Slots = new string[] { "*" }; config.TenantId = new TenantId("A"); config.BucketInfo = new List <BucketInfo>(); config.BucketInfo.Add(new BucketInfo() { Slots = new[] { "*" }, BufferSize = 10000 }); _identityConverter = new IdentityManager(new CounterService(_db)); _identityConverter.RegisterIdentitiesFromAssembly(typeof(SampleAggregateId).Assembly); ConfigureEventStore(); CommitEnhancer commitEnhancer = new CommitEnhancer(_identityConverter); _eventUnwinder = new EventUnwinder(config, new TestLogger(LoggerLevel.Info)); _unwindedEventCollection = _db.GetCollection <UnwindedDomainEvent>("UnwindedEvents"); MongoFlatMapper.EnableFlatMapping(true); MongoFlatIdSerializerHelper.Initialize(_identityConverter); var rebuildContext = new RebuildContext(NitroEnabled); _storageFactory = new MongoStorageFactory(_db, rebuildContext); _reader1 = new MongoReader <SampleReadModel, string>(_db); _reader2 = new MongoReader <SampleReadModel2, string>(_db); _reader3 = new MongoReader <SampleReadModel3, string>(_db); //now configure RebuildProjectionEngine _tracker = new ConcurrentCheckpointTracker(_db); var projections = BuildProjections().ToArray(); _tracker.SetUp(projections, 1, false); ProjectionEventInspector inspector = new ProjectionEventInspector(); inspector.AddAssembly(Assembly.GetExecutingAssembly()); sut = new RebuildProjectionEngine(_eventUnwinder, _tracker, projections, rebuildContext, config, inspector); sut.Logger = new TestLogger(LoggerLevel.Debug); _checkpointCollection = _db.GetCollection <Checkpoint>("checkpoints"); }
public void verify_reset() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); sut.InspectProjectionForEvents(typeof(TestProjectionCatchAll)); Assert.That(sut.EventHandled, Has.Count.EqualTo(sut.TotalEventCount)); sut.ResetHandledEvents(); sut.InspectProjectionForEvents(typeof(TestProjectionInherited)); Assert.That(sut.EventHandled, Is.EquivalentTo(new[] { typeof(SampleAggregateCreated), typeof(SampleAggregateTouched) })); }
public void verify_get_each_call_return_correct_number_of_event() { ProjectionEventInspector sut = new ProjectionEventInspector(); sut.AddAssembly(Assembly.GetExecutingAssembly()); var result = sut.InspectProjectionForEvents(typeof(Projection)); Assert.That(result, Is.EquivalentTo(new[] { typeof(SampleAggregateCreated) })); result = sut.InspectProjectionForEvents(typeof(TestProjectionTouched)); Assert.That(result, Is.EquivalentTo(new[] { typeof(SampleAggregateTouched) })); //Combine the two projection events togheter. Assert.That(sut.EventHandled, Is.EquivalentTo(new[] { typeof(SampleAggregateCreated), typeof(SampleAggregateTouched) })); }