Example #1
0
        public void Add_ThrowsException_WhenKeyIsNull()
        {
            _dictionary = new SingleDictionary <string, string>();
            Action Do = () => _dictionary.Add(null, "value2");

            Do.Should().Throw <ArgumentNullException>();
        }
Example #2
0
        public void Construct_WithEmptyDictionaryParameter_IsEmpty()
        {
            var dict   = new Dictionary <string, string>();
            var target = new SingleDictionary <string, string>(dict);

            target.AsEnumerable().Should().BeEmpty();
        }
Example #3
0
 public void Add_AddKeyValue_WhenDictionaryIsEmpty()
 {
     _dictionary = new SingleDictionary <string, string>();
     _dictionary.Add(new  KeyValuePair <string, string> ("key2", "value2"));
     _dictionary.AsEnumerable().Should().BeEquivalentTo(new KeyValuePair <string, string>[] {
         new KeyValuePair <string, string>("key2", "value2")
     });
 }
Example #4
0
        public void Remove_ReturnsFalse_WhenKeyNotFound_WhenEmpty()
        {
            _dictionary = new SingleDictionary <string, string>();
            var res = _dictionary.Remove("Key");

            res.Should().BeFalse();
            _dictionary.AsEnumerable().Should().BeEmpty();
        }
Example #5
0
        public SingleDictionaryTest()
        {
            var Dictionary = new Dictionary <string, string>()
            {
                { "key", "value" }
            };

            _dictionary = new SingleDictionary <string, string>(Dictionary);
        }
Example #6
0
        public void Construct_WithOversizedDictionaryParameter_ThrowException()
        {
            var dict = new Dictionary <string, string>()
            {
                { "key2", "value2" },
                { "key1", "value1" }
            };
            SingleDictionary <string, string> target = null;
            Action Do = () => { target = new SingleDictionary <string, string>(dict); };

            Do.Should().Throw <ArgumentOutOfRangeException>();
        }