Esempio n. 1
0
        public void When_Dictionary_UpdateItem_RetunsSameValue_Then_DictionaryNotUpdated()
        {
            var key = new object();

            // **I**ImmutableDictionary
            IImmutableDictionary <object, object> dictionary_interface = ImmutableDictionary <object, object> .Empty.Add(key, new object());

            var dictionary_interface_capture = dictionary_interface;

            Transactional.UpdateItem(ref dictionary_interface, key, (k, v) => v);

            Assert.AreSame(dictionary_interface_capture, dictionary_interface);

            // ImmutableDictionary
            ImmutableDictionary <object, object> dictionary_implementation = ImmutableDictionary <object, object> .Empty.Add(key, new object());

            var dictionary_implementation_capture = dictionary_implementation;

            Transactional.TryUpdateItem(ref dictionary_implementation, key, (k, v) => v);

            Assert.AreSame(dictionary_implementation_capture, dictionary_implementation);

            // ImmutableSortedDictionary
            ImmutableSortedDictionary <object, object> dictionary_sorted = ImmutableSortedDictionary <object, object> .Empty.Add(key, new object());

            var dictionary_sorted_capture = dictionary_sorted;

            Transactional.TryUpdateItem(ref dictionary_sorted, key, (k, v) => v);

            Assert.AreSame(dictionary_sorted_capture, dictionary_sorted);
        }