コード例 #1
0
        // Adds an object to the store, then removes it again
        public void TestRemove()
        {
            var store = new ObjectStore();

            string key = "MyObject1";
            var    obj = ValidObjectFactory(1);

            bool added = store.AddOrUpdate(key, obj);

            Assert.IsTrue(added, "Failed to add object to the object store");

            bool exists = store.Exists(key);

            Assert.IsTrue(exists, "Object was not found in the object store");

            bool removed = store.Remove(key);

            Assert.IsTrue(removed, "Object could not be removed from the object store");

            bool doesNotExist = !store.Exists(key);

            Assert.IsTrue(doesNotExist, "Object was still found in the object store, even though it should have been removed");
        }
コード例 #2
0
        public static void CheckedAddToStore(ObjectStore store, string key, IStoredType obj)
        {
            bool added = store.AddOrUpdate(key, obj);

            Assert.IsTrue(added, "Failed to add object to the object store");

            bool exists = store.Exists(key);

            Assert.IsTrue(exists, "Object was not found in the object store");

            IStoredObject <IStoredType> retrievedObj = null;
            bool retrievedSuccess = store.GetByName <IStoredType>(key, out retrievedObj);

            Assert.IsTrue(retrievedSuccess, "Object could not be retrieved from the object store");

            bool retrievedObjectEqualsOriginal = retrievedObj.Object.Equals(obj);

            Assert.IsTrue(retrievedObjectEqualsOriginal, "Retrieved object does not equal original object");
        }