public void SaveSagaData(
     MongoSagaPersister sut,
     MongoDatabaseFactory factory,
     DeviceCommandSagaState state)
 {
     sut.Save(state);
 }
 public void SaveSagaData(
     MongoSagaPersister sut,
     MongoDatabaseFactory factory,
     DeviceCommandSagaState state)
 {
     sut.Save(state);
 }
Exemple #3
0
 public void InterleavedSavingSagaShouldThrowException(
     MongoSagaPersister sut,
     MongoDatabaseFactory factory,
     SagaWithUniqueProperty sagaData)
 {
     sut.Save(sagaData);
     sut.Invoking(s => s.Save(sagaData)).ShouldThrow <MongoDuplicateKeyException>();
 }
Exemple #4
0
        public void RetrievingSagaUsingStringUniqueId(
            MongoSagaPersister sut,
            SagaWithUniqueProperty sagaData)
        {
            sut.Save(sagaData);

            var result = sut.Get <SagaWithUniqueProperty>("UniqueProperty", sagaData.UniqueProperty);

            result.ShouldBeEquivalentTo(sagaData);
        }
Exemple #5
0
        public void RetrievingSagaUsingGuidUniqueId(
            MongoSagaPersister sut,
            SagaWithUniqueGuidProperty sagaData)
        {
            sut.Save(sagaData);

            var result = sut.Get <SagaWithUniqueGuidProperty>("SomeId", sagaData.SomeId);

            result.ShouldBeEquivalentTo(sagaData);
        }
Exemple #6
0
        public void RetrievingSagaUsingId(
            MongoSagaPersister sut,
            SagaWithoutUniqueProperties sagaData)
        {
            sut.Save(sagaData);

            var result = sut.Get <SagaWithoutUniqueProperties>(sagaData.Id);

            result.ShouldBeEquivalentTo(sagaData);
        }
Exemple #7
0
        public void CompletingSagaShouldRemoveDocument(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithoutUniqueProperties sagaData)
        {
            sut.Save(sagaData);

            sut.Complete(sagaData);
            factory.RetrieveSagaData(sagaData).Should().BeNull();
        }
        public void SaveSagaData(
            MongoSagaPersister sut,
            DeviceCommandSagaState state,
            SynchronizedStorageSession session,
            ContextBag context)
        {
            var correlationProperty = new SagaCorrelationProperty("SagaKey", state.SagaKey);

            sut.Save(state, correlationProperty, session, context).Wait();
        }
 public void InterleavedSavingSagaShouldThrowException(
     MongoSagaPersister sut,
     MongoDatabaseFactory factory,
     SagaWithUniqueProperty sagaData,
     SagaCorrelationProperty correlationProperty,
     SynchronizedStorageSession session,
     ContextBag context)
 {
     sut.Save(sagaData, correlationProperty, session, context).Wait();
     sut.Invoking(s => s.Save(sagaData, correlationProperty, session, context).Wait())
     .ShouldThrow <MongoWriteException>();
 }
Exemple #10
0
        public void SavingSagaWithSameUniquePropertyAsAnAlreadyCompletedSaga(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData1,
            SagaWithUniqueProperty sagaData2)
        {
            var uniqueProperty = Guid.NewGuid().ToString();

            sagaData1.UniqueProperty = uniqueProperty;
            sagaData2.UniqueProperty = uniqueProperty;

            sut.Save(sagaData1);
            sut.Complete(sagaData1);

            sut.Save(sagaData2);

            var entity = factory.RetrieveSagaData(sagaData2);

            entity.UniqueProperty.Should().Be(sagaData2.UniqueProperty);
            entity.NonUniqueProperty.Should().Be(sagaData2.NonUniqueProperty);
        }
Exemple #11
0
        public void SavingSagaWithoutUniqueProperty(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithoutUniqueProperties sagaData)
        {
            sut.Save(sagaData);

            var entity = factory.RetrieveSagaData(sagaData);

            entity.Id.Should().Be(sagaData.Id);
            entity.NonUniqueProperty.Should().Be(sagaData.NonUniqueProperty);
        }
        public void SavingSagaWithoutUniqueProperty(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithoutUniqueProperties sagaData)
        {
            sut.Save(sagaData);

            var entity = factory.RetrieveSagaData(sagaData);

            entity.Id.Should().Be(sagaData.Id);
            entity.NonUniqueProperty.Should().Be(sagaData.NonUniqueProperty);
        }
        public void CompletingSagaShouldRemoveDocument(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData,
            SagaCorrelationProperty correlationProperty,
            SynchronizedStorageSession session,
            ContextBag context)
        {
            sut.Save(sagaData, correlationProperty, session, context).Wait();

            sut.Complete(sagaData, session, context).Wait();
            factory.RetrieveSagaData(sagaData).Should().BeNull();
        }
        public void RetrievingSagaUsingId(
            MongoSagaPersister sut,
            SagaWithUniqueProperty sagaData,
            SagaCorrelationProperty correlationProperty,
            SynchronizedStorageSession session,
            ContextBag context)
        {
            sut.Save(sagaData, correlationProperty, session, context).Wait();

            var result = sut.Get <SagaWithUniqueProperty>(sagaData.Id, session, context).Result;

            result.ShouldBeEquivalentTo(sagaData);
        }
Exemple #15
0
        public void SavingDifferentSagaWithSameUniquePropertyShouldThrowDuplicateException(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData1,
            SagaWithUniqueProperty sagaData2)
        {
            var uniqueProperty = Guid.NewGuid().ToString();

            sagaData1.UniqueProperty = uniqueProperty;
            sagaData2.UniqueProperty = uniqueProperty;

            sut.Save(sagaData1);
            sut.Invoking(s => s.Save(sagaData2)).ShouldThrow <MongoDuplicateKeyException>();
        }
Exemple #16
0
        public void UpdatingSagaWithUniqueProperty(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData,
            string newValue)
        {
            sut.Save(sagaData);

            sagaData.NonUniqueProperty = newValue;
            sut.Update(sagaData);

            var entity = factory.RetrieveSagaData(sagaData);

            entity.NonUniqueProperty.Should().Be(newValue);
        }
Exemple #17
0
        public void UpdateCollisionShouldFail(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData)
        {
            sut.Save(sagaData);
            var saga1 = factory.RetrieveSagaData(sagaData);
            var saga2 = factory.RetrieveSagaData(sagaData);

            saga1.UniqueProperty = Guid.NewGuid().ToString();
            sut.Update(saga1);

            saga2.UniqueProperty = Guid.NewGuid().ToString();
            sut.Invoking(s => s.Update(saga2)).ShouldThrow <InvalidOperationException>();
        }
        public void SavingSagaWithSameUniquePropertyAsAnAlreadyCompletedSaga(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData1,
            SagaWithUniqueProperty sagaData2,
            SagaCorrelationProperty correlationProperty,
            SynchronizedStorageSession session,
            ContextBag context)
        {
            var uniqueProperty = Guid.NewGuid().ToString();

            sagaData1.UniqueProperty = uniqueProperty;
            sagaData2.UniqueProperty = uniqueProperty;

            sut.Save(sagaData1, correlationProperty, session, context).Wait();
            sut.Complete(sagaData1, session, context).Wait();

            sut.Save(sagaData2, correlationProperty, session, context).Wait();

            var entity = factory.RetrieveSagaData(sagaData2);

            entity.UniqueProperty.Should().Be(sagaData2.UniqueProperty);
            entity.SomeValue.Should().Be(sagaData2.SomeValue);
        }
        public void SavingSagaWithUniqueProperty(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData,
            SagaCorrelationProperty correlationProperty,
            SynchronizedStorageSession session,
            ContextBag context)
        {
            sut.Save(sagaData, correlationProperty, session, context).Wait();

            var entity = factory.RetrieveSagaData(sagaData);

            entity.Id.Should().Be(sagaData.Id);
            entity.UniqueProperty.Should().Be(sagaData.UniqueProperty);
            entity.SomeValue.Should().Be(sagaData.SomeValue);
        }
        public void UpdatingSagaWithNoChangesShouldNotUpdateVersion(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData,
            SagaCorrelationProperty correlationProperty,
            SynchronizedStorageSession session,
            ContextBag context)
        {
            sut.Save(sagaData, correlationProperty, session, context).Wait();
            var saga1 = factory.RetrieveSagaData(sagaData);

            sut.Update(saga1, session, context).Wait();

            var saga2 = factory.RetrieveSagaData(sagaData);

            saga2.DocumentVersion.Should().Be(saga1.DocumentVersion);
        }
        public void UpdateCollisionShouldFail(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData,
            SagaCorrelationProperty correlationProperty,
            SynchronizedStorageSession session,
            ContextBag context)
        {
            sut.Save(sagaData, correlationProperty, session, context).Wait();
            var saga1 = factory.RetrieveSagaData(sagaData);
            var saga2 = factory.RetrieveSagaData(sagaData);

            saga1.UniqueProperty = Guid.NewGuid().ToString();
            sut.Update(saga1, session, context).Wait();

            saga2.UniqueProperty = Guid.NewGuid().ToString();
            sut.Invoking(s => s.Update(saga2, session, context).Wait()).ShouldThrow <InvalidOperationException>();
        }
        public void SavingDifferentSagaWithSameUniquePropertyShouldThrowDuplicateException(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData1,
            SagaWithUniqueProperty sagaData2)
        {
            var uniqueProperty = Guid.NewGuid().ToString();
            sagaData1.UniqueProperty = uniqueProperty;
            sagaData2.UniqueProperty = uniqueProperty;

            sut.Save(sagaData1);
            sut.Invoking(s => s.Save(sagaData2)).ShouldThrow<MongoDuplicateKeyException>();
        }
        public void RetrievingSagaUsingId(
            MongoSagaPersister sut,
            SagaWithoutUniqueProperties sagaData)
        {
            sut.Save(sagaData);

            var result = sut.Get<SagaWithoutUniqueProperties>(sagaData.Id);

            result.ShouldBeEquivalentTo(sagaData);
        }
        public void UpdatingSagaWithUniqueProperty(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData,
            string newValue)
        {
            sut.Save(sagaData);

            sagaData.NonUniqueProperty = newValue;
            sut.Update(sagaData);

            var entity = factory.RetrieveSagaData(sagaData);
            entity.NonUniqueProperty.Should().Be(newValue);
        }
        public void SavingSagaWithSameUniquePropertyAsAnAlreadyCompletedSaga(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData1,
            SagaWithUniqueProperty sagaData2)
        {
            var uniqueProperty = Guid.NewGuid().ToString();
            sagaData1.UniqueProperty = uniqueProperty;
            sagaData2.UniqueProperty = uniqueProperty;

            sut.Save(sagaData1);
            sut.Complete(sagaData1);

            sut.Save(sagaData2);

            var entity = factory.RetrieveSagaData(sagaData2);
            entity.UniqueProperty.Should().Be(sagaData2.UniqueProperty);
            entity.NonUniqueProperty.Should().Be(sagaData2.NonUniqueProperty);
        }
        public void UpdateCollisionShouldFail(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithUniqueProperty sagaData)
        {
            sut.Save(sagaData);
            var saga1 = factory.RetrieveSagaData(sagaData);
            var saga2 = factory.RetrieveSagaData(sagaData);

            saga1.UniqueProperty = Guid.NewGuid().ToString();
            sut.Update(saga1);

            saga2.UniqueProperty = Guid.NewGuid().ToString();
            sut.Invoking(s => s.Update(saga2)).ShouldThrow<InvalidOperationException>();
        }
        public void CompletingSagaShouldRemoveDocument(
            MongoSagaPersister sut,
            MongoDatabaseFactory factory,
            SagaWithoutUniqueProperties sagaData)
        {
            sut.Save(sagaData);

            sut.Complete(sagaData);
            factory.RetrieveSagaData(sagaData).Should().BeNull();
        }
        public void RetrievingSagaUsingGuidUniqueId(
            MongoSagaPersister sut,
            SagaWithUniqueGuidProperty sagaData)
        {
            sut.Save(sagaData);

            var result = sut.Get<SagaWithUniqueGuidProperty>("SomeId", sagaData.SomeId);

            result.ShouldBeEquivalentTo(sagaData);
        }
        public void RetrievingSagaUsingStringUniqueId(
            MongoSagaPersister sut,
            SagaWithUniqueProperty sagaData)
        {
            sut.Save(sagaData);

            var result = sut.Get<SagaWithUniqueProperty>("UniqueProperty", sagaData.UniqueProperty);

            result.ShouldBeEquivalentTo(sagaData);
        }
 public void InterleavedSavingSagaShouldThrowException(
     MongoSagaPersister sut,
     MongoDatabaseFactory factory,
     SagaWithUniqueProperty sagaData)
 {
     sut.Save(sagaData);
     sut.Invoking(s => s.Save(sagaData)).ShouldThrow<MongoDuplicateKeyException>();
 }