public void verify_new_projection_when_zero_events_dispatched() { //Two projection in the same slot var projection1 = new Projection(Substitute.For <ICollectionWrapper <SampleReadModel, String> >()); var projection2 = new Projection2(Substitute.For <ICollectionWrapper <SampleReadModel2, String> >()); //A projection in other slot var projection3 = new Projection3(Substitute.For <ICollectionWrapper <SampleReadModel3, String> >()); var projections = new IProjection[] { projection1, projection2, projection3 }; var checkpoint1 = new Checkpoint(projection1.GetCommonName(), 1, projection1.GetSignature()); var checkpoint2 = new Checkpoint(projection2.GetCommonName(), 1, projection2.GetSignature()); var checkpoint3 = new Checkpoint(projection3.GetCommonName(), 0, projection3.GetSignature()); _checkPoints.InsertMany(new[] { checkpoint1, checkpoint2, checkpoint3 }); _sut = new ConcurrentCheckpointTracker(_db); var status = _sut.GetSlotsStatus(projections); Assert.That(status.NewSlots, Is.EquivalentTo(new[] { projection3.GetSlotName() })); }
public void verify_slot_status_all_ok() { //Two projection in the same slot var projection1 = new Projection(Substitute.For <ICollectionWrapper <SampleReadModel, String> >()); var projection2 = new Projection2(Substitute.For <ICollectionWrapper <SampleReadModel2, String> >()); //A projection in other slot var projection3 = new Projection3(Substitute.For <ICollectionWrapper <SampleReadModel3, String> >()); var projections = new IProjection[] { projection1, projection2, projection3 }; var checkpoint1 = new Checkpoint(projection1.GetCommonName(), 1, projection1.GetSignature()); var checkpoint2 = new Checkpoint(projection2.GetCommonName(), 1, projection2.GetSignature()); var checkpoint3 = new Checkpoint(projection3.GetCommonName(), 1, projection3.GetSignature()); _checkPoints.InsertMany(new[] { checkpoint1, checkpoint2, checkpoint3 }); _sut = new ConcurrentCheckpointTracker(_db); var status = _sut.GetSlotsStatus(projections); Assert.That(status.NewSlots, Has.Count.EqualTo(0)); Assert.That(status.SlotsThatNeedsRebuild, Has.Count.EqualTo(0)); }
private IProjection[] SetupTwoProjectionsError() { _sut = new ConcurrentCheckpointTracker(_db); var rebuildContext = new RebuildContext(false); var storageFactory = new MongoStorageFactory(_db, rebuildContext); var writer1 = new CollectionWrapper <SampleReadModel, string>(storageFactory, new NotifyToNobody()); var writer2 = new CollectionWrapper <SampleReadModel2, string>(storageFactory, new NotifyToNobody()); var projection1 = new Projection(writer1); var projection2 = new Projection2(writer2); var projections = new IProjection[] { projection1, projection2 }; var p1 = new Checkpoint(projection1.GetCommonName(), 42, projection1.GetSignature()); p1.Slot = projection1.GetSlotName(); _checkPoints.Save(p1, p1.Id); var p2 = new Checkpoint(projection2.GetCommonName(), 40, projection2.GetSignature()); p2.Slot = projection1.GetSlotName(); _checkPoints.Save(p2, p2.Id); _sut.SetUp(projections, 1, false); return(projections); }