public void RedisStorageStoresAndRemovesObjects() { var objectToStore = "my object"; var objectName = Guid.NewGuid().ToString(); using (var storage = new RedisStorage(RedisStorageTests.Host)) { storage.Store(objectName, objectToStore); storage.Remove(objectName); Assert.That(() => storage.Retrieve<string>(objectName), Throws.InstanceOf<ArgumentOutOfRangeException>()); } }
public void RedisStorageStoresAndRetrievesComplexObjects() { var objectToStore = new ComplexParameter() { SomeProperty = "this is string", AnotherProperty = 47 }; var objectName = Guid.NewGuid().ToString(); using (var storage = new RedisStorage(RedisStorageTests.Host)) { storage.Store(objectName, objectToStore); var retrievedObject = storage.Retrieve<ComplexParameter>(objectName); retrievedObject.SomeProperty.ShouldBe(objectToStore.SomeProperty); retrievedObject.AnotherProperty.ShouldBe(objectToStore.AnotherProperty); } }
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 RedisStorageThrowsArgumentOutOfRangeExceptionWhenTryingToGetNotExistingObject() { var objectName = Guid.NewGuid().ToString(); using (var storage = new RedisStorage(RedisStorageTests.Host)) { Assert.That(() => storage.Retrieve<string>(objectName), Throws.InstanceOf<ArgumentOutOfRangeException>()); } }
public void RedisStorageStoresAndRetrievesObjects() { var objectToStore = "my object"; var objectName = Guid.NewGuid().ToString(); using (var storage = new RedisStorage(RedisStorageTests.Host)) { storage.Store(objectName, objectToStore); string retrievedObject = storage.Retrieve<string>(objectName); retrievedObject.ShouldBe(objectToStore); } }