public void ConcurrentOrderedMap_Supports_AddOrUpdate()
        {
            var dict   = new ConcurrentOrderedDictionary <string, string>();
            var result = dict.AddOrUpdate("foo", "bar", (k, v) => "baz");

            Assert.Single(dict);
            Assert.Equal("bar", result);

            result = dict.AddOrUpdate("foo", "baz", (k, v) => "baz");

            Assert.Single(dict);
            Assert.Equal("baz", result);
        }
        public void ConcurrentOrderedMap_AddOrUpdate_PassesOldValueForExistingItem()
        {
            var dict = new ConcurrentOrderedDictionary <string, string>();

            dict.AddOrUpdate("foo", "bar", (k, v) => "baz");

            string callbackValue = null;

            dict.AddOrUpdate("foo", "baz", (k, v) => {
                callbackValue = v;
                return("baz");
            });

            Assert.Equal("bar", callbackValue);
        }
        public void ConcurrentOrderedMap_AddOrUpdate_UpdateCallbackNotCalledForNewItem()
        {
            var dict = new ConcurrentOrderedDictionary <string, string>();

            string callbackValue = null;

            dict.AddOrUpdate("foo", "bar", (k, v) => {
                callbackValue = v;
                return("baz");
            });

            Assert.Null(callbackValue);
        }