public void Verify_projection_change_info_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.Info.CommonName, 1, projection1.Info.Signature) { Slot = projection1.Info.SlotName }; var checkpoint2 = new Checkpoint(projection2.Info.CommonName, 1, projection2.Info.Signature) { Slot = projection2.Info.SlotName }; var checkpoint3 = new Checkpoint(projection3.Info.CommonName, 1, projection3.Info.Signature) { Slot = projection3.Info.SlotName }; _checkPoints.InsertMany(new[] { checkpoint1, checkpoint2, checkpoint3 }); _slotStatusCheckerSut = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray()); var status = _slotStatusCheckerSut.GetProjectionChangeInfo(); Assert.That(status.Count(), Is.EqualTo(3)); Assert.That(status.All(s => s.ChangeType == ProjectionChangeInfo.ProjectionChangeType.None)); }
public void Verify_projection_change_info_new_projection() { 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.Info.CommonName, 1, projection1.Info.Signature) { Slot = projection1.Info.SlotName }; var checkpoint2 = new Checkpoint(projection2.Info.CommonName, 1, projection2.Info.Signature) { Slot = projection2.Info.SlotName }; _checkPoints.InsertMany(new[] { checkpoint1, checkpoint2, }); _concurrentCheckpointTrackerSut = new ConcurrentCheckpointTracker(_db); _slotStatusCheckerSut = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray()); var status = _slotStatusCheckerSut.GetProjectionChangeInfo(); Assert.That(status.Count(), Is.EqualTo(3)); var none = status.Where(s => s.ChangeType == ProjectionChangeInfo.ProjectionChangeType.None); Assert.That(none.Count(), Is.EqualTo(2)); var singleChange = status.Single(s => s.ChangeType == ProjectionChangeInfo.ProjectionChangeType.NewProjection); Assert.That(singleChange.CommonName, Is.EqualTo(projection3.Info.CommonName)); }
public void Verify_slot_status_new_projection() { //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.Info.CommonName, 1, projection1.Info.Signature); var checkpoint2 = new Checkpoint(projection2.Info.CommonName, 1, projection2.Info.Signature); checkpoint1.Current = checkpoint1.Value; checkpoint2.Current = checkpoint2.Value; _checkPoints.InsertMany(new[] { checkpoint1, checkpoint2, }); _concurrentCheckpointTrackerSut = new ConcurrentCheckpointTracker(_db, 60); _slotStatusCheckerSut = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray()); var status = _slotStatusCheckerSut.GetSlotsStatus(); Assert.That(status.NewSlots, Is.EquivalentTo(new[] { projection3.Info.SlotName })); Assert.That(status.SlotsThatNeedsRebuild, Has.Count.EqualTo(0)); }
public void Verify_slot_status_all_ok_with_no_checkpoints() { //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 }; _slotStatusCheckerSut = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray()); var status = _slotStatusCheckerSut.GetSlotsStatus(); Assert.That(status.AllSlots, Has.Count.EqualTo(2)); }
public void verify_slot_status_new_projection_when_db_empty() { //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 }; _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)); }
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)); }
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.Info.CommonName, 1, projection1.Info.Signature); var checkpoint2 = new Checkpoint(projection2.Info.CommonName, 1, projection2.Info.Signature); var checkpoint3 = new Checkpoint(projection3.Info.CommonName, 0, projection3.Info.Signature); _checkPoints.InsertMany(new[] { checkpoint1, checkpoint2, checkpoint3 }); _concurrentCheckpointTrackerSut = new ConcurrentCheckpointTracker(_db, 60); _slotStatusCheckerSut = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray()); var status = _slotStatusCheckerSut.GetSlotsStatus(); Assert.That(status.NewSlots, Is.EquivalentTo(new[] { projection3.Info.SlotName })); }