상속: IContainSagaData
예제 #1
0
        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);
            try
            {
                SaveSaga(saga2);
                Assert.Fail("SaveSaga should throw an exception");
            }
            catch (MongoWriteException aggEx)
            {
                // Check for "E11000 duplicate key error"
                // https://docs.mongodb.org/manual/reference/command/insert/

                Assert.AreEqual(11000, aggEx.WriteError?.Code);
            }
        }
        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");
        }
예제 #3
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");
        }
예제 #4
0
        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 <MongoDuplicateKeyException>(() => SaveSaga(saga2));
        }
        public async Task It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty()
            {
                Id              = Guid.NewGuid(),
                UniqueString    = "whatever",
                NonUniqueString = "notUnique"
            };

            await SaveSaga(saga1).ConfigureAwait(false);

            await UpdateSaga <SagaWithUniqueProperty>(saga1.Id, s => s.NonUniqueString = "notUnique2").ConfigureAwait(false);

            saga1 = await LoadSaga <SagaWithUniqueProperty>(saga1.Id).ConfigureAwait(false);

            Assert.AreEqual("notUnique2", saga1.NonUniqueString);
        }
        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<MongoDuplicateKeyException>(() => SaveSaga(saga2));
        }
예제 #7
0
        public async Task It_should_persist_successfully()
        {
            var saga1 = new SagaWithUniqueProperty
            {
                Id           = Guid.NewGuid(),
                UniqueString = "whatever"
            };

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

            await SaveSaga(saga1).ConfigureAwait(false);
            await CompleteSaga <SagaWithUniqueProperty>(saga1.Id).ConfigureAwait(false);
            await SaveSaga(saga2).ConfigureAwait(false);
        }
        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 async Task It_should_should_enforce_uniqueness()
        {
            var saga = new SagaWithUniqueProperty()
            {
                Id              = Guid.NewGuid(),
                UniqueString    = "abc",
                NonUniqueString = "notUnique"
            };

            await SaveSaga(saga).ConfigureAwait(false);


            saga.Id = Guid.NewGuid();
            var writeException = Assert.ThrowsAsync <MongoWriteException>(() => SaveSaga(saga));

            // Check for "E11000 duplicate key error"
            // https://docs.mongodb.org/manual/reference/command/insert/
            Assert.AreEqual(11000, writeException?.WriteError?.Code);
        }