public void InsertDoesPersistSagaData() { var persister = CreatePersister(createTables: true); var propertyName = Reflect.Path <SomePieceOfSagaData>(d => d.PropertyThatCanBeNull); var dataWithIndexedNullProperty = new SomePieceOfSagaData { SomeValueWeCanRecognize = "hello" }; persister.Insert(dataWithIndexedNullProperty, new[] { propertyName }); var count = ExecuteScalar(string.Format("SELECT COUNT(*) FROM {0}", Dialect.QuoteForTableName(SagaTableName))); Assert.That(count, Is.EqualTo(1)); }
public void EnsuresUniquenessAlsoOnCorrelationPropertyWithNull() { var propertyName = Reflect.Path <SomePieceOfSagaData>(d => d.PropertyThatCanBeNull); var dataWithIndexedNullProperty = new SomePieceOfSagaData { SomeValueWeCanRecognize = "hello" }; var anotherPieceOfDataWithIndexedNullProperty = new SomePieceOfSagaData { SomeValueWeCanRecognize = "hello" }; persister.Insert(dataWithIndexedNullProperty, new[] { propertyName }); Assert.Throws <OptimisticLockingException>(() => persister.Insert(dataWithIndexedNullProperty, new[] { propertyName })); }
public void EnsuresUniquenessAlsoOnCorrelationPropertyWithNull() { var persister = CreatePersister(createTables: true); var propertyName = Reflect.Path <SomePieceOfSagaData>(d => d.PropertyThatCanBeNull); var dataWithIndexedNullProperty = new SomePieceOfSagaData { Id = Guid.NewGuid(), SomeValueWeCanRecognize = "hello" }; var anotherPieceOfDataWithIndexedNullProperty = new SomePieceOfSagaData { Id = Guid.NewGuid(), SomeValueWeCanRecognize = "hello" }; persister.Insert(dataWithIndexedNullProperty, new[] { propertyName }); Assert.That( () => persister.Insert(anotherPieceOfDataWithIndexedNullProperty, new[] { propertyName }), (persister is ICanUpdateMultipleSagaDatasAtomically) ? (IResolveConstraint)Throws.Nothing : Throws.Exception ); }
public void CanFindAndUpdateSagaDataByCorrelationPropertyWithNull() { var propertyName = Reflect.Path <SomePieceOfSagaData>(d => d.PropertyThatCanBeNull); var dataWithIndexedNullProperty = new SomePieceOfSagaData { SomeValueWeCanRecognize = "hello" }; persister.Insert(dataWithIndexedNullProperty, new[] { propertyName }); var sagaDataFoundViaNullProperty = persister.Find <SomePieceOfSagaData>(propertyName, null); Assert.That(sagaDataFoundViaNullProperty, Is.Not.Null, "Could not find saga data with (null) on the correlation property {0}", propertyName); Assert.That(sagaDataFoundViaNullProperty.SomeValueWeCanRecognize, Is.EqualTo("hello")); sagaDataFoundViaNullProperty.SomeValueWeCanRecognize = "hwello there!!1"; persister.Update(sagaDataFoundViaNullProperty, new[] { propertyName }); var sagaDataFoundAgainViaNullProperty = persister.Find <SomePieceOfSagaData>(propertyName, null); Assert.That(sagaDataFoundAgainViaNullProperty, Is.Not.Null, "Could not find saga data with (null) on the correlation property {0} after having updated it", propertyName); Assert.That(sagaDataFoundAgainViaNullProperty.SomeValueWeCanRecognize, Is.EqualTo("hwello there!!1")); }