public void TestIndexString(string key, string value) { var sut = new CustomDataMap(); sut.SetString(key, value); Check.That(sut[key]).IsEqualTo(value); }
public void TestNullKeyNotAllowed() { var sut = new CustomDataMap(); Check.ThatCode(() => sut.SetString(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.SetBool(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.SetLong(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.SetULong(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.SetXElement(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.GetString(null)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.GetBool(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.GetLong(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.GetULong(null, default)).Throws <ArgumentNullException>(); Check.ThatCode(() => sut.GetXElement(null, default)).Throws <ArgumentNullException>(); }
public void TestItemEnumeration() { var data = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" }, { "key3", "value3" } }; var sut = new CustomDataMap(); foreach (var kv in data) { sut.SetString(kv.Key, kv.Value); } Check.That(sut).IsEquivalentTo(data); }
public void TestRemoveItem() { const string KeyToRemove = "key2"; var data = new Dictionary <string, string> { { "key1", "value1" }, { KeyToRemove, "value2" }, { "key3", "value3" } }; var sut = new CustomDataMap(); foreach (var kv in data) { sut.SetString(kv.Key, kv.Value); } sut.RemoveValue(KeyToRemove); Check.That(sut).IsEquivalentTo(data.Where(kv => kv.Key != KeyToRemove)); }