public void It_should_set_the_attribute_and_allow_the_update()
        {
            var saga1 = new SagaWithUniqueProperty()
            {
                Id = Guid.NewGuid(),
                UniqueString = "whatever",
                NonUniqueString = "notUnique"
            };

            SaveSaga(saga1);

            using(var session = store.OpenSession())
            {
                //fake that the attribute was just added by removing the metadata
                session.Advanced.GetMetadataFor(saga1).Remove(RavenSagaPersister.UniqueValueMetadataKey);
                session.SaveChanges();
            }

            UpdateSaga<SagaWithUniqueProperty>(saga1.Id, s => s.UniqueString = "whatever2");

            string value;

            using (var session = store.OpenSession())
                value = session.Advanced.GetMetadataFor(saga1)[RavenSagaPersister.UniqueValueMetadataKey].ToString();

            Assert.AreEqual("whatever2",value);
        }
        public void It_should_set_the_attribute_and_allow_the_update()
        {
            var uniqueString = Guid.NewGuid().ToString();

            var anotherUniqueString = Guid.NewGuid().ToString();

            var saga1 = new SagaWithUniqueProperty()
            {
                Id              = Guid.NewGuid(),
                UniqueString    = uniqueString,
                NonUniqueString = "notUnique"
            };

            SaveSaga(saga1);

            using (var session = store.OpenSession())
            {
                //fake that the attribute was just added by removing the metadata
                session.Advanced.GetMetadataFor(saga1).Remove(RavenSagaPersister.UniqueValueMetadataKey);
                session.SaveChanges();
            }

            UpdateSaga <SagaWithUniqueProperty>(saga1.Id, s => s.UniqueString = anotherUniqueString);

            string value;

            using (var session = store.OpenSession())
                value = session.Advanced.GetMetadataFor(saga1)[RavenSagaPersister.UniqueValueMetadataKey].ToString();

            Assert.AreEqual(anotherUniqueString, value);
        }
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty { Id = Guid.NewGuid(), UniqueString = "whatever"};

            var inMemorySagaPersister = new InMemorySagaPersister() as ISagaPersister;
            inMemorySagaPersister.Save(saga1);
            saga1 = inMemorySagaPersister.Get<SagaWithUniqueProperty>(saga1.Id);
            inMemorySagaPersister.Update(saga1);
        }
        public void should_throw_a_ArgumentNullException()
        {
            string uniqueString = null;
            var saga1 = new SagaWithUniqueProperty
                            {
                                Id = Guid.NewGuid(),
                                UniqueString = uniqueString
                            };

            SaveSaga(saga1);
        }
        public void should_throw_a_ArgumentNullException()
        {
            string uniqueString = null;
            var    saga1        = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = uniqueString
            };

            SaveSaga(saga1);
        }
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty {
                Id = Guid.NewGuid(), UniqueString = "whatever"
            };

            var inMemorySagaPersister = new InMemorySagaPersister() as ISagaPersister;

            inMemorySagaPersister.Save(saga1);
            saga1 = inMemorySagaPersister.Get <SagaWithUniqueProperty>(saga1.Id);
            inMemorySagaPersister.Update(saga1);
        }
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty()
                        {
                            Id = Guid.NewGuid(),
                            UniqueString = "whatever",
                            NonUniqueString = "notUnique"
                        };

            SaveSaga(saga1);

            UpdateSaga<SagaWithUniqueProperty>(saga1.Id, s => s.NonUniqueString = "notUnique2");
        }
Esempio n. 8
0
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty()
            {
                Id              = Guid.NewGuid(),
                UniqueString    = "whatever",
                NonUniqueString = "notUnique"
            };

            SaveSaga(saga1);

            UpdateSaga <SagaWithUniqueProperty>(saga1.Id, s => s.NonUniqueString = "notUnique2");
        }
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty {Id = Guid.NewGuid(), UniqueString = "whatever1"};
            var saga2 = new SagaWithUniqueProperty {Id = Guid.NewGuid(), UniqueString = "whatever"};
            var inMemorySagaPersister = new InMemorySagaPersister();

            inMemorySagaPersister.Save(saga1);
            inMemorySagaPersister.Save(saga2);

            Assert.Throws<InvalidOperationException>(() =>
            {
                var saga = inMemorySagaPersister.Get<SagaWithUniqueProperty>(saga2.Id);
                saga.UniqueString = "whatever1";
                inMemorySagaPersister.Update(saga);
            });
        }
        public void It_should_enforce_uniqueness()
        {
            var saga1 = new SagaWithUniqueProperty
                        {
                            Id = Guid.NewGuid(),
                            UniqueString = "whatever"
                        };

            var saga2 = new SagaWithUniqueProperty
                        {
                            Id = Guid.NewGuid(),
                            UniqueString = "whatever"
                        };

            SaveSaga(saga1);
            Assert.Throws<ConcurrencyException>(() => SaveSaga(saga2));
        }
        public void It_should_enforce_uniqueness()
        {
            var saga1 = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = "whatever"
            };

            var saga2 = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = "whatever"
            };

            SaveSaga(saga1);
            Assert.Throws <ConcurrencyException>(() => SaveSaga(saga2));
        }
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty
            {
                Id = Guid.NewGuid(),
                UniqueString = "whatever"
            };

            var saga2 = new SagaWithUniqueProperty
            {
                Id = Guid.NewGuid(),
                UniqueString = "whatever"
            };

            SaveSaga(saga1);
            CompleteSaga<SagaWithUniqueProperty>(saga1.Id);
            SaveSaga(saga2);
        }
Esempio n. 13
0
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = "whatever"
            };

            var saga2 = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = "whatever"
            };

            SaveSaga(saga1);
            CompleteSaga <SagaWithUniqueProperty>(saga1.Id);
            SaveSaga(saga2);
        }
        public void It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty {
                Id = Guid.NewGuid(), UniqueString = "whatever1"
            };
            var saga2 = new SagaWithUniqueProperty {
                Id = Guid.NewGuid(), UniqueString = "whatever"
            };
            var inMemorySagaPersister = new InMemorySagaPersister() as ISagaPersister;

            inMemorySagaPersister.Save(saga1);
            inMemorySagaPersister.Save(saga2);

            Assert.Throws <InvalidOperationException>(() =>
            {
                var saga          = inMemorySagaPersister.Get <SagaWithUniqueProperty>(saga2.Id);
                saga.UniqueString = "whatever1";
                inMemorySagaPersister.Update(saga);
            });
        }
        public void It_should_allow_the_update()
        {
            var saga1 = new SagaWithUniqueProperty
                        {
                            Id = Guid.NewGuid(),
                            UniqueString = "whatever1"
                        };

            SaveSaga(saga1);

            UpdateSaga<SagaWithUniqueProperty>(saga1.Id, s => s.UniqueString = "whatever2");

            var saga2 = new SagaWithUniqueProperty
            {
                Id = Guid.NewGuid(),
                UniqueString = "whatever1"
            };

            //this should not blow since we changed the uniq value in the previous saga
            SaveSaga(saga2);
        }
Esempio n. 16
0
        public void It_should_allow_the_update()
        {
            var saga1 = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = "whatever1"
            };

            SaveSaga(saga1);

            UpdateSaga <SagaWithUniqueProperty>(saga1.Id, s => s.UniqueString = "whatever2");

            var saga2 = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = "whatever1"
            };

            //this should not blow since we changed the uniq value in the previous saga
            SaveSaga(saga2);
        }