Esempio n. 1
0
        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>());
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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>());
                }
            }
        }
Esempio n. 4
0
 public void RedisStorageThrowsArgumentOutOfRangeExceptionWhenTryingToGetNotExistingObject()
 {
     var objectName = Guid.NewGuid().ToString();
     using (var storage = new RedisStorage(RedisStorageTests.Host))
     {
         Assert.That(() => storage.Retrieve<string>(objectName), Throws.InstanceOf<ArgumentOutOfRangeException>());
     }
 }
Esempio n. 5
0
        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);
            }
        }