Ejemplo n.º 1
0
        public void SetIndexer_IDictionary(string input)
        {
            IDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>();

            dict[input] = default;
            Assert.True(dict.ContainsKey(input));
        }
Ejemplo n.º 2
0
        public void Contains_IDictionary(string input)
        {
            IDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>();

            dict.Add(input, true);
            Assert.True(dict.ContainsKey(input));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        public void KeyNotNull()
        {
            KeyThrowingDictionary <string, bool> dict = new KeyThrowingDictionary <string, bool>();

            Assert.Throws <ArgumentNullException>(() => dict.Add(null, true));
        }