public void GetStringValue() { var d = new ReadOnlyDictionary <string, string>(new Dictionary <string, string> { { "key_a", "value_a" } }); Assert.That(d.GetStringValue("key_a"), Is.EqualTo("value_a")); Assert.Throws <InvalidOperationException>(() => d.GetStringValue("key_b")); Assert.That(d.TryGetStringValue("key_a", out var value), Is.True); Assert.That(value, Is.EqualTo("value_a")); Assert.That(d.TryGetStringValue("key_b", 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 _)); }