public async Task XmlRoundTripsToActualRedisServer() { var connStr = TestRedisServer.GetConnectionString(); _output.WriteLine("Attempting to connect to " + connStr); var guid = Guid.NewGuid().ToString(); RedisKey key = "Test:DP:Key" + guid; try { using (var redis = await ConnectionMultiplexer.ConnectAsync(connStr).TimeoutAfter(TimeSpan.FromMinutes(1))) { var repo = new RedisXmlRepository(() => redis.GetDatabase(), key); var element = new XElement("HelloRedis", guid); repo.StoreElement(element, guid); } using (var redis = await ConnectionMultiplexer.ConnectAsync(connStr).TimeoutAfter(TimeSpan.FromMinutes(1))) { var repo = new RedisXmlRepository(() => redis.GetDatabase(), key); var elements = repo.GetAllElements(); Assert.Contains(elements, e => e.Name == "HelloRedis" && e.Value == guid); } } finally { // cleanup using (var redis = await ConnectionMultiplexer.ConnectAsync(connStr).TimeoutAfter(TimeSpan.FromMinutes(1))) { await redis.GetDatabase().KeyDeleteAsync(key); } } }
public void StoreElement_PushesValueToList() { var database = new Mock <IDatabase>(); database.Setup(d => d.ListRightPush("Key", "<Element2 />", When.Always, CommandFlags.None)).Verifiable(); var repo = new RedisXmlRepository(() => database.Object, "Key"); repo.StoreElement(new XElement("Element2"), null); database.Verify(); }