public void RedisStorageStoresAndRemovesObjectsInBulks() { KeyValuePair<string, string>[] objectsToStore = new KeyValuePair<string, string>[100]; for (int i = 0; i < objectsToStore.Length; i++) { objectsToStore[i] = new KeyValuePair<string, string>(Guid.NewGuid().ToString(), "jack checked chicken"); } using (var storage = new RedisStorage(RedisStorageTests.Host)) { storage.BulkStore(objectsToStore); storage.BulkRemove(objectsToStore.Select(o => o.Key).ToArray()); foreach (var @object in objectsToStore) { Assert.That(() => storage.Retrieve<string>(@object.Key), Throws.InstanceOf<ArgumentOutOfRangeException>()); } } }
public void RedisStorageStoresAndRetrievesComplexObjectsInBulks() { var objectToStore = new ComplexParameter() { SomeProperty = "this is string", AnotherProperty = 47 }; KeyValuePair<string, ComplexParameter>[] objectsToStore = new KeyValuePair<string, ComplexParameter>[100]; for (int i = 0; i < objectsToStore.Length; i++) { objectsToStore[i] = new KeyValuePair<string, ComplexParameter>(Guid.NewGuid().ToString(), objectToStore); } using (var storage = new RedisStorage(RedisStorageTests.Host)) { storage.BulkStore(objectsToStore); var retrievedObjects = storage.BulkRetrieve<ComplexParameter>(objectsToStore.Select(o => o.Key).ToArray()); foreach (var retrievedObject in retrievedObjects) { retrievedObject.SomeProperty.ShouldBe(objectToStore.SomeProperty); retrievedObject.AnotherProperty.ShouldBe(objectToStore.AnotherProperty); } } }