Esempio n. 1
0
        public void AddsKeyIfDoesntExist()
        {
            var dictionary = new Dictionary<string, string>();

            var result = dictionary.AddOnlyIfDoesntExist("hello", "goodbye");

            Assert.True(result);
            Assert.Equal("goodbye", dictionary["hello"]);
        }
Esempio n. 2
0
        public void ReturnsFalseWhenKeyIsNotAdded()
        {
            var dictionary = new Dictionary<string, string>
            {
                {"hello", "goodbye"}
            };

            var result = dictionary.AddOnlyIfDoesntExist("hello", "goodbye2");

            Assert.False(result);
            Assert.Equal("goodbye", dictionary["hello"]);
        }