Beispiel #1
0
        public void ESLoadEvents()
        {
            FakeVersionedEntity feeOriginal = new FakeVersionedEntity();

            FakeVersionedEntity feeRestored = new FakeVersionedEntity(feeOriginal.Id);

            feeOriginal.RaiseFakeEvent(new FakeEvent()
            {
                TestString = "a"
            });
            feeOriginal.RaiseFakeEvent(new FakeEvent()
            {
                TestString = "b"
            });
            feeOriginal.RaiseFakeEvent(new FakeEvent()
            {
                TestString = "c"
            });

            FakeEventSourcedRepository.Save(feeOriginal);

            FakeEventSourcedRepository.Load(feeRestored);

            Assert.AreEqual(feeOriginal.FakeString, feeRestored.FakeString, "Not the same string.");
            Assert.AreEqual(feeOriginal.Events.Count, 0, "Original with events.");
            Assert.AreEqual(feeRestored.Events.Count, 0, "Restored with events.");
        }
Beispiel #2
0
        public void ESSaveEntityFailedSaving()
        {
            testAction.MarkExceptionSavingDbSet <TimeoutException>(1, true);

            FakeVersionedEntity fee = new FakeVersionedEntity();

            fee.Events.Enqueue(new FakeEvent());
            FakeEventSourcedRepository.Save(fee);
        }
Beispiel #3
0
        public void ESSaveEntityFailedPublishSuceeded()
        {
            testAction.MarkExceptionSavingDbSet <Exception>(1, false);

            FakeVersionedEntity fee = new FakeVersionedEntity();

            fee.Events.Enqueue(new FakeEvent());
            FakeEventSourcedRepository.Save(fee);

            Assert.IsTrue(fee.Events.Count == 0, "Must no be events pending in queue");
            Assert.AreEqual(Store.EnvelopeId.ToString(), fee.Id.ToString());
        }
Beispiel #4
0
        public void ESSaveEntityFailedPublishing()
        {
            Guid g = Guid.NewGuid();
            FakeVersionedEntity fee = new FakeVersionedEntity();

            fee.Events.Enqueue(new FakeEvent());
            fee.Events.Enqueue(new FakeFailedEvent());
            fee.Events.Enqueue(new FakeEvent());
            FakeEventSourcedRepository.Save(fee);

            Assert.IsTrue(fee.Events.Count == 1, "One event pending in queue");
            Assert.AreEqual(Store.EnvelopeId.ToString(), typeof(FakeFailedEvent).Name);
        }
Beispiel #5
0
        public void ESSaveEntity()
        {
            FakeEvent fe = new FakeEvent();

            FakeVersionedEntity fee = new FakeVersionedEntity();

            fee.Events.Enqueue(fe);
            FakeEventSourcedRepository.Save(fee);

            Assert.IsTrue(fee.Events.Count == 0, "Events in queue");
            Assert.IsTrue(String.IsNullOrEmpty(Store.EnvelopeId), "Different IDs");
            Assert.AreEqual(Store.Id, fee.Id, "Different IDs");
        }
Beispiel #6
0
        public void ESSaveEntityFailedSavingAfterFailedPublishing()
        {
            testAction.MarkExceptionSavingDbSet <Exception>(1, false);

            FakeVersionedEntity fee = new FakeVersionedEntity();

            fee.Events.Enqueue(new FakeEvent());
            fee.Events.Enqueue(new FakeFailedEvent());
            fee.Events.Enqueue(new FakeEvent());
            FakeEventSourcedRepository.Save(fee);

            Assert.IsTrue(fee.Events.Count == 1, "One event pending in queue");
            Assert.AreEqual(Store.EnvelopeId.ToString(), typeof(FakeFailedEvent).Name);
        }