Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public void Verify_projection_change_info_for_projection_that_changed_slot_and_signature()
        {
            //Two projection in the same slot
            var projection1 = new Projection(Substitute.For <ICollectionWrapper <SampleReadModel, String> >());

            var projections = new IProjection[] { projection1 };
            var checkpoint1 = new Checkpoint(projection1.Info.CommonName, 1, projection1.Info.Signature + "modified")
            {
                Slot = projection1.Info.SlotName + "modified"
            };

            _checkPoints.InsertMany(new[] { checkpoint1, });

            _concurrentCheckpointTrackerSut = new ConcurrentCheckpointTracker(_db);
            _slotStatusCheckerSut           = new SlotStatusManager(_db, projections.Select(p => p.Info).ToArray());
            var status = _slotStatusCheckerSut.GetProjectionChangeInfo();
            var singleProjectionStatus = status.Single();

            Assert.That((Int32)(singleProjectionStatus.ChangeType | ProjectionChangeInfo.ProjectionChangeType.SlotChange), Is.GreaterThan(0));
            Assert.That((Int32)(singleProjectionStatus.ChangeType | ProjectionChangeInfo.ProjectionChangeType.SignatureChange), Is.GreaterThan(0));

            Assert.That(singleProjectionStatus.OldSlot, Is.EqualTo(projection1.Info.SlotName + "modified"));
            Assert.That(singleProjectionStatus.ActualSlot, Is.EqualTo(projection1.Info.SlotName));
            Assert.That(singleProjectionStatus.OldSignature, Is.EqualTo(projection1.Info.Signature + "modified"));
            Assert.That(singleProjectionStatus.ActualSignature, Is.EqualTo(projection1.Info.Signature));
        }
Esempio n. 3
0
        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));
        }