Exemple #1
0
        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));
        }
Exemple #2
0
        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 }));
        }
Exemple #3
0
        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
                );
        }
Exemple #4
0
        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"));
        }