public void GetIntValue() { var d = new ReadOnlyDictionary <string, string>(new Dictionary <string, string> { { "key_a", "value_a" }, { "key_b", "42" } }); Assert.Throws <InvalidOperationException>(() => d.GetIntValue("key_a")); Assert.That(d.GetIntValue("key_b"), Is.EqualTo(42)); Assert.Throws <InvalidOperationException>(() => d.GetIntValue("key_c")); Assert.That(d.TryGetIntValue("key_a", out var value), Is.False); Assert.That(d.TryGetIntValue("key_b", out value), Is.True); Assert.That(value, Is.EqualTo(42)); Assert.That(d.TryGetIntValue("key_c", out value), Is.False); }
public void ArgumentExceptions() { ReadOnlyDictionary <string, string> d = null; Assert.Throws <ArgumentNullException>(() => d.GetStringValue("key")); Assert.Throws <ArgumentNullException>(() => d.TryGetStringValue("key", out _)); Assert.Throws <ArgumentNullException>(() => d.GetGuidValue("key")); Assert.Throws <ArgumentNullException>(() => d.TryGetGuidValue("key", out _)); Assert.Throws <ArgumentNullException>(() => d.GetIntValue("key")); Assert.Throws <ArgumentNullException>(() => d.TryGetIntValue("key", out _)); }