Exemplo n.º 1
0
        public void Tree_should_supported_hash_conflicting_keys()
        {
            var key1 = new HashConflictingKey <string>("a");
            var key2 = new HashConflictingKey <string>("b");
            var key3 = new HashConflictingKey <string>("c");
            var tree = ImHashMap <HashConflictingKey <string>, int> .Empty
                       .AddOrUpdate(key1, 1)
                       .AddOrUpdate(key2, 2)
                       .AddOrUpdate(key3, 3);

            var value = tree.GetValueOrDefault(key3);

            Assert.That(value, Is.EqualTo(3));
        }
Exemplo n.º 2
0
        public void When_adding_value_with_hash_conflicted_key_Then_I_should_be_able_to_get_it_back()
        {
            var key1 = new HashConflictingKey <string>("a", 1);
            var key2 = new HashConflictingKey <string>("b", 1);
            var key3 = new HashConflictingKey <string>("c", 1);
            var tree = HashTree <HashConflictingKey <string>, int> .Empty
                       .AddOrUpdate(key1, 1)
                       .AddOrUpdate(key2, 2)
                       .AddOrUpdate(key3, 3);

            var value = tree.GetValueOrDefault(key3);

            Assert.That(value, Is.EqualTo(3));
        }
Exemplo n.º 3
0
        public void When_adding_couple_of_values_with_hash_conflicted_key_Then_I_should_be_able_to_get_them_back()
        {
            var key1 = new HashConflictingKey <string>("a", 1);
            var key2 = new HashConflictingKey <string>("b", 1);
            var key3 = new HashConflictingKey <string>("c", 1);
            var tree = HashTree <HashConflictingKey <string>, int> .Empty
                       .AddOrUpdate(key1, 1)
                       .AddOrUpdate(key2, 2)
                       .AddOrUpdate(key3, 3);

            var values = tree.Enumerate().ToDictionary(kv => kv.Key.Key, kv => kv.Value);

            Assert.That(values, Is.EqualTo(new Dictionary <string, int>
            {
                { "a", 1 },
                { "b", 2 },
                { "c", 3 },
            }));
        }