public void GetOrAdd3Test() { using (var gridion = GridionFactory.Start()) { IDistributedDictionary <string, DictionaryTestObject> dictionary = gridion.GetDictionary <string, DictionaryTestObject>("testDictionary"); var expected = new DictionaryTestObject(1); var actual = dictionary.GetOrAdd("key", (_, _) => expected, 0d); Assert.IsNotNull(actual, "actual != null."); Assert.AreEqual(expected, actual, "The objects are different."); Assert.AreEqual(1, dictionary.Count, "The collection size is invalid."); actual = dictionary.GetOrAdd("key", expected); Assert.IsNotNull(actual, "actual != null."); Assert.AreEqual(1, dictionary.Count, "The collection size is invalid."); } }
public void SetIndexedFromDictionaryProperty() { DictionaryTestObject to = new DictionaryTestObject(); IObjectWrapper wrapper = GetWrapper(to); to.Dictionary = new Hashtable(); wrapper.SetPropertyValue("Dictionary['key1']", "value1"); Assert.AreEqual("value1", to.Dictionary["key1"]); }
public void GetIndexMissingFromDictionaryProperty() { DictionaryTestObject to = new DictionaryTestObject(); IObjectWrapper wrapper = GetWrapper(to); to.Dictionary = new Hashtable(); Assert.IsNull(wrapper.GetPropertyValue("Dictionary['notthere']")); }
public void GetIndexedFromDictionaryProperty() { DictionaryTestObject to = new DictionaryTestObject(); IObjectWrapper wrapper = GetWrapper(to); to.Dictionary = new Hashtable(); to.Dictionary.Add("key1", "value1"); Assert.AreEqual("value1", (string) wrapper.GetPropertyValue("Dictionary['key1']")); }