public void SetIndexer_IDictionary(string input) { IDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>(); dict[input] = default; Assert.True(dict.ContainsKey(input)); }
public void Contains_IDictionary(string input) { IDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>(); dict.Add(input, true); Assert.True(dict.ContainsKey(input)); }
public void Contains_IReadOnlyDictionary(string input) { KeyThrowingDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>(); dict.Add(input, true); Assert.True(((IReadOnlyDictionary <string, bool>)dict).ContainsKey(input)); }
public void Missing_IDictionary(string input) { IDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>(); Assert.Throws <KeyNotFoundException>(() => dict[input]); try { var discard = dict[input]; Assert.True(false); } catch (KeyNotFoundException ex) { Assert.Contains(input.ToString(), ex.Message); return; } Assert.True(false); }
public void DoubleAdd(string input) { KeyThrowingDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>(); dict.Add(input, true); Assert.Throws <ArgumentException>(() => dict.Add(input, true)); try { dict.Add(input, true); Assert.True(false); } catch (ArgumentException ex) { Assert.Contains(input.ToString(), ex.Message); return; } Assert.True(false); }
public void KeyNotNull() { KeyThrowingDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>(); Assert.Throws <ArgumentNullException>(() => dict.Add(null, true)); }