<value>Collection was modified; enumeration operation may not execute.</value>
</data>
<data name="DuplicateKey" xml:space="preserve">
- <value>An element with the same key but a different value already exists. Key: {0}</value>
+ <value>An element with the same key but a different value already exists. Key: '{0}'</value>
</data>
<data name="InvalidEmptyOperation" xml:space="preserve">
<value>This operation does not apply to an empty instance.</value>
return value;
}
- throw new KeyNotFoundException();
+ throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}
}
Assert.True(clearedDictionary.ContainsKey("A"));
}
+ [Fact]
+ public void Indexer_KeyNotFoundException_ContainsKeyInMessage()
+ {
+ var map = ImmutableDictionary.Create<string, string>()
+ .Add("a", "1").Add("b", "2");
+ var exception = Assert.Throws<KeyNotFoundException>(() => map["c"]);
+ Assert.Contains("'c'", exception.Message);
+ }
+
protected override IImmutableDictionary<TKey, TValue> Empty<TKey, TValue>()
{
return ImmutableDictionaryTest.Empty<TKey, TValue>();
Assert.Throws<KeyNotFoundException>(() => dictionary.ValueRef("c"));
}
+ [Fact]
+ public void Indexer_KeyNotFoundException_ContainsKeyInMessage()
+ {
+ var map = ImmutableSortedDictionary.Create<string, string>()
+ .Add("a", "1").Add("b", "2");
+ var exception = Assert.Throws<KeyNotFoundException>(() => map["c"]);
+ Assert.Contains("'c'", exception.Message);
+ }
+
protected override IImmutableDictionary<TKey, TValue> Empty<TKey, TValue>()
{
return ImmutableSortedDictionaryTest.Empty<TKey, TValue>();