예제 #1
0
        public void Test_Saga_Persister_Concurrency_Check_Works()
        {
            var clientManager = new PooledRedisClientManager();

            clientManager.GetClient().FlushDb();

            var store = new RedisSagaPersister(new JsonSerializer(), clientManager);

            var data = new TestSagaData()
            {
                Id            = Guid.NewGuid(),
                CorrelationId = Guid.NewGuid(),
                Name          = "Hello world"
            };

            store.Save(data);

            data.Name = data.Name + " modified";

            store.Update(data);

            var data2 = store.Get <TestSagaData>(data.Id);

            store.Update(data2);

            store.Update(data);             //Causes concurrency exception
        }
예제 #2
0
        public void Test_Saga_Persister_Store_And_Retrieve_Works()
        {
            var clientManager = new PooledRedisClientManager();

            clientManager.GetClient().FlushDb();

            var store = new RedisSagaPersister(new JsonSerializer(), clientManager);

            var data1 = new TestSagaData()
            {
                Id            = Guid.NewGuid(),
                CorrelationId = Guid.NewGuid(),
                Name          = "Hello world"
            };

            store.Save(data1);

            data1.Name = data1.Name + " modified";

            store.Update(data1);

            var data2 = store.Get <TestSagaData>(data1.Id);

            Assert.AreEqual(data1.Name, data2.Name);

            var data3 = store.Get <TestSagaData>("CorrelationId", data1.CorrelationId);

            Assert.AreEqual(data3.CorrelationId, data1.CorrelationId);

            store.Complete(data1);

            Assert.IsTrue(clientManager.GetClient().SearchKeys("nservicebus:*").Count == 0);
        }
예제 #3
0
        public void Test_Saga_Persister_Unique_Check_Works()
        {
            var clientManager = new PooledRedisClientManager();

            clientManager.GetClient().FlushDb();

            var store = new RedisSagaPersister(new JsonSerializer(), clientManager);

            var data = new TestSagaData()
            {
                Id            = Guid.NewGuid(),
                CorrelationId = Guid.NewGuid(),
                Name          = "Hello world"
            };

            var copy = new TestSagaData()
            {
                Id            = Guid.NewGuid(),
                CorrelationId = data.CorrelationId,
                Name          = "Copy"
            };

            store.Save(data);

            store.Save(copy);             //Expect exception here
        }