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, SagaWithoutUniqueProperties sagaData) { sut.Save(sagaData); sut.Complete(sagaData); factory.RetrieveSagaData(sagaData).Should().BeNull(); }
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 UpdatingNonExistantSagaWithUniqueProperty( MongoSagaPersister sut, MongoDatabaseFactory factory, SagaWithUniqueProperty sagaData) { sut.Invoking(s => s.Update(sagaData)).ShouldThrow<InvalidOperationException>(); factory.RetrieveSagaData(sagaData).Should().BeNull(); }
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); }