public void SetUp() { _source = new PropertyBag(); _source.Add("key", "val1"); _source.Add("key", "val2"); _source.Add("meaningOfLife", 42); _adapter = new PropertyBagAdapter(_source); }
public void PropertyBagAdapter_UpdatesWhenSourcePropertyBagUpdates() { _source.Add("newKey", "newVal"); Assert.IsTrue(_adapter.ContainsKey("newKey")); Assert.AreEqual("newVal", _adapter.Get("newKey")); CollectionAssert.AreEquivalent(new string[] { "newVal" }, _adapter["newKey"]); Assert.AreEqual(1, _adapter.Count("newKey")); CollectionAssert.AreEquivalent(new string[] { "key", "meaningOfLife", "newKey" }, _adapter.Keys); }
internal static void AddCrossJoinedRange(this IPropertyBag propertyBag, IEnumerable <string> keys, IEnumerable <string> values) { foreach (string key in keys) { foreach (string value in values) { if (!propertyBag[key].Contains(value)) { propertyBag.Add(key, value); } } } }