public void Test_Timeout_Persistence_RemoveTimeoutBy_Works() { var clientManager = new PooledRedisClientManager(); var store = new RedisTimeoutPersistence(new JsonSerializer(), clientManager); store.EndpointName = "timeouttest"; clientManager.GetClient().FlushDb(); var data = new TimeoutData() { SagaId = Guid.NewGuid(), Time = DateTime.UtcNow.AddSeconds(-30), OwningTimeoutManager = store.EndpointName, Destination = Address.Parse("test@localhost"), }; store.Add(data); store.RemoveTimeoutBy(data.SagaId); DateTime nextRun; var timeouts = store.GetNextChunk(DateTime.UtcNow.AddMinutes(-2), out nextRun); Assert.IsEmpty(timeouts); }
public void Should_Insert_Item_To_SortedSet() { using (var redisClient = _fixture.RedisClientsManager.GetClient()) { redisClient.SortedSets[EndpointName].Clear(); _redisTimeoutPersistence.Add(new TimeoutData { Id = "Hello", Time = DateTime.UtcNow }); Assert.Equal(1, redisClient.GetSortedSetCount(EndpointName)); } }
public void Test_Timeout_Persistence_TryRemove_Works() { var clientManager = new PooledRedisClientManager(); var store = new RedisTimeoutPersistence(new JsonSerializer(), clientManager); store.EndpointName = "timeouttest"; clientManager.GetClient().FlushDb(); var data = new TimeoutData() { SagaId = Guid.NewGuid(), Time = DateTime.UtcNow.AddSeconds(-30), OwningTimeoutManager = store.EndpointName, Destination = Address.Parse("test@access-djz9x4j"), }; store.Add(data); DateTime nextRun; var timeouts = store.GetNextChunk(DateTime.UtcNow.AddMinutes(-2), out nextRun); Assert.IsNotEmpty(timeouts); TimeoutData removedData = null; if (store.TryRemove(timeouts.First().Item1, out removedData)) { Assert.AreEqual(removedData.SagaId, data.SagaId); } else { throw new Exception("Couldn't remove"); } }