public virtual void map()
        {
            IList <string> expected = ImmutableList.of("one1", "two2", "three3", "four4");
            IList <string> result   = MapStream.of(map_Renamed).map((k, v) => k + v).collect(toList());

            assertThat(result).isEqualTo(expected);
        }
        public virtual void mapKeysToKeys()
        {
            IDictionary <string, int> expected = ImmutableMap.of("ONE", 1, "TWO", 2, "THREE", 3, "FOUR", 4);
            IDictionary <string, int> result   = MapStream.of(map_Renamed).mapKeys(k => k.ToUpper(Locale.ENGLISH)).toMap();

            assertThat(result).isEqualTo(expected);
        }
        public virtual void mapValuesToValues()
        {
            IDictionary <string, int> expected = ImmutableMap.of("one", 2, "two", 4, "three", 6, "four", 8);
            IDictionary <string, int> result   = MapStream.of(map_Renamed).mapValues(v => v * 2).toMap();

            assertThat(result).isEqualTo(expected);
        }
        //-------------------------------------------------------------------------
        public virtual void ofMultimap()
        {
            ImmutableMultimap <string, int> input = ImmutableMultimap.of("one", 1, "two", 2, "one", 3);

            assertThat(MapStream.of(input)).containsExactlyInAnyOrder(entry("one", 1), entry("two", 2), entry("one", 3));
            assertThat(MapStream.of(input).toMap(int?.sum)).containsOnly(entry("one", 4), entry("two", 2));
        }
        public virtual void mapKeysAndValuesToValues()
        {
            IDictionary <string, string> expected = ImmutableMap.of("one", "one1", "two", "two2", "three", "three3", "four", "four4");
            IDictionary <string, string> result   = MapStream.of(map_Renamed).mapValues((k, v) => k + v).toMap();

            assertThat(result).isEqualTo(expected);
        }
        //-------------------------------------------------------------------------
        public virtual void filter()
        {
            IDictionary <string, int> expected = ImmutableMap.of("one", 1, "two", 2);
            IDictionary <string, int> result   = MapStream.of(map_Renamed).filter((k, v) => k.Equals("one") || v == 2).toMap();

            assertThat(result).isEqualTo(expected);
        }
        //-----------------------------------------------------------------------
        public virtual void forEach()
        {
            Dictionary <object, object> mutableMap = new Dictionary <object, object>();

            MapStream.of(map_Renamed).forEach((k, v) => mutableMap.put(k, v));
            assertThat(mutableMap).isEqualTo(map_Renamed);
        }
        public virtual void filterValues_byClass()
        {
            IDictionary <Number, Number> map    = ImmutableMap.of(1, 11, 2d, 22, 3, 33d);
            IDictionary <Number, int>    result = MapStream.of(map).filterValues(typeof(Integer)).toMap();

            assertThat(result).isEqualTo(ImmutableMap.of(1, 11, 2d, 22));
        }
        public virtual void filterValues()
        {
            IDictionary <string, int> expected = ImmutableMap.of("one", 1, "two", 2);
            IDictionary <string, int> result   = MapStream.of(map_Renamed).filterValues(v => v < 3).toMap();

            assertThat(result).isEqualTo(expected);
        }
        public virtual void flatMapKeysAndValuesToKeys()
        {
            IDictionary <string, int> expected = ImmutableMap.builder <string, int>().put("one", 1).put("1", 1).put("two", 2).put("2", 2).put("three", 3).put("3", 3).put("four", 4).put("4", 4).build();

            ImmutableMap <string, int> result = MapStream.of(map_Renamed).flatMapKeys((key, value) => Stream.of(key, Convert.ToString(value))).toMap();

            assertThat(result).isEqualTo(expected);
        }
        public virtual void sortedValues_comparator()
        {
            IList <KeyValuePair <string, int> > expected = ImmutableList.of(entry("four", 4), entry("three", 3), entry("two", 2), entry("one", 1));

            IList <KeyValuePair <string, int> > result = MapStream.of(map_Renamed).sortedValues(System.Collections.IComparer.reverseOrder()).collect(toList());

            assertThat(result).isEqualTo(expected);
        }
        //-----------------------------------------------------------------------
        public virtual void sortedKeys()
        {
            IList <KeyValuePair <string, int> > expected = ImmutableList.of(entry("four", 4), entry("one", 1), entry("three", 3), entry("two", 2));

            IList <KeyValuePair <string, int> > result = MapStream.of(map_Renamed).sortedKeys().collect(toList());

            assertThat(result).isEqualTo(expected);
        }
        public virtual void flatMap()
        {
            IDictionary <string, string> expected = ImmutableMap.builder <string, string>().put("one", "1").put("1", "one").put("two", "2").put("2", "two").put("three", "3").put("3", "three").put("four", "4").put("4", "four").build();

            IDictionary <string, string> result = MapStream.of(map_Renamed).flatMap((k, v) => Stream.of(Pair.of(k, Convert.ToString(v)), Pair.of(Convert.ToString(v), k))).collect(pairsToImmutableMap());

            assertThat(result).isEqualTo(expected);
        }
        public virtual void flatMapKeysAndValuesToValues()
        {
            IList <Pair <string, string> > expected = ImmutableList.of(Pair.of("one", "one"), Pair.of("one", "1"), Pair.of("two", "two"), Pair.of("two", "2"), Pair.of("three", "three"), Pair.of("three", "3"), Pair.of("four", "four"), Pair.of("four", "4"));

            IList <Pair <string, string> > result = MapStream.of(map_Renamed).flatMapValues((key, value) => Stream.of(key, Convert.ToString(value))).map((k, v) => Pair.of(k, v)).collect(toList());

            assertThat(result).isEqualTo(expected);
        }
        public virtual void flatMapValuesToValues()
        {
            IList <Pair <string, int> > expected = ImmutableList.of(Pair.of("one", 1), Pair.of("one", 1), Pair.of("two", 2), Pair.of("two", 4), Pair.of("three", 3), Pair.of("three", 9), Pair.of("four", 4), Pair.of("four", 16));

            IList <Pair <string, int> > result = MapStream.of(map_Renamed).flatMapValues(value => Stream.of(value, value * value)).map((k, v) => Pair.of(k, v)).collect(toList());

            assertThat(result).isEqualTo(expected);
        }
        public virtual void concatGeneric()
        {
            ImmutableMap <string, object> map1   = ImmutableMap.of("one", 1, "two", 2, "three", 3);
            ImmutableMap <object, int>    map2   = ImmutableMap.of("three", 7, "four", 4);
            ImmutableMap <object, object> result = MapStream.concat(MapStream.of(map1), MapStream.of(map2)).toMap((a, b) => a);

            assertThat(result).isEqualTo(map_Renamed);
        }
        public virtual void ofStream_2arg()
        {
            Stream <string> letters = Stream.of("a", "b", "c");
            IDictionary <string, string> expected = ImmutableMap.of("A", "aa", "B", "bb", "C", "cc");
            IDictionary <string, string> result   = MapStream.of(letters, letter => letter.ToUpper(Locale.ENGLISH), letter => letter + letter).toMap();

            assertThat(result).isEqualTo(expected);
        }
        public virtual void ofCollection()
        {
            IList <string> letters = ImmutableList.of("a", "b", "c");
            IDictionary <string, string> expected = ImmutableMap.of("A", "a", "B", "b", "C", "c");
            IDictionary <string, string> result   = MapStream.of(letters, letter => letter.ToUpper(Locale.ENGLISH)).toMap();

            assertThat(result).isEqualTo(expected);
        }
        public virtual void flatMapKeysToKeys()
        {
            IDictionary <string, int> expected = ImmutableMap.builder <string, int>().put("one", 1).put("ONE", 1).put("two", 2).put("TWO", 2).put("three", 3).put("THREE", 3).put("four", 4).put("FOUR", 4).build();

            ImmutableMap <string, int> result = MapStream.of(map_Renamed).flatMapKeys(key => Stream.of(key.ToLower(Locale.ENGLISH), key.ToUpper(Locale.ENGLISH))).toMap();

            assertThat(result).isEqualTo(expected);
        }
        public virtual void toMapGroupingWithCollector()
        {
            IDictionary <string, int> map      = ImmutableMap.of("a", 1, "aa", 2, "b", 10, "bb", 20, "c", 1);
            IDictionary <string, int> expected = ImmutableMap.of("a", 3, "b", 30, "c", 1);
            IDictionary <string, int> result   = MapStream.of(map).mapKeys(s => s.substring(0, 1)).toMapGrouping(reducing(0, int?.sum));

            assertThat(result).isEqualTo(expected);
        }
        //-------------------------------------------------------------------------
        public virtual void toListMultimap()
        {
            IDictionary <string, int>  map      = ImmutableMap.of("a", 1, "aa", 2, "b", 10, "bb", 20, "c", 1);
            ListMultimap <string, int> expected = ImmutableListMultimap.of("a", 1, "a", 2, "b", 10, "b", 20, "c", 1);
            ListMultimap <string, int> result   = MapStream.of(map).mapKeys(s => s.substring(0, 1)).toListMultimap();

            assertThat(result).isEqualTo(expected);
        }
        //-------------------------------------------------------------------------
        public virtual void toMapGrouping()
        {
            IDictionary <string, int>          map      = ImmutableMap.of("a", 1, "aa", 2, "b", 10, "bb", 20, "c", 1);
            IDictionary <string, IList <int> > expected = ImmutableMap.of("a", list(1, 2), "b", list(10, 20), "c", list(1));
            IDictionary <string, IList <int> > result   = MapStream.of(map).mapKeys(s => s.substring(0, 1)).toMapGrouping();

            assertThat(result).isEqualTo(expected);
        }
        public virtual void toMapWithMerge()
        {
            IDictionary <string, int> map      = ImmutableMap.of("a", 1, "aa", 2, "b", 10, "bb", 20, "c", 1);
            IDictionary <string, int> expected = ImmutableMap.of("a", 3, "b", 30, "c", 1);
            IDictionary <string, int> result   = MapStream.of(map).mapKeys(s => s.substring(0, 1)).toMap((v1, v2) => v1 + v2);

            assertThat(result).isEqualTo(expected);
        }
        public virtual void sortedValues()
        {
            ImmutableMap <string, int> invertedValuesMap = ImmutableMap.of("one", 4, "two", 3, "three", 2, "four", 1);

            IList <KeyValuePair <string, int> > expected = ImmutableList.of(entry("four", 1), entry("three", 2), entry("two", 3), entry("one", 4));

            IList <KeyValuePair <string, int> > result = MapStream.of(invertedValuesMap).sortedValues().collect(toList());

            assertThat(result).isEqualTo(expected);
        }
        public virtual void concatNumberValues()
        {
            ImmutableMap <string, double> map1 = ImmutableMap.of("one", 1D, "two", 2D, "three", 3D);
            ImmutableMap <object, int>    map2 = ImmutableMap.of("three", 7, "four", 4);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableMap<Object, ? extends Number> result = MapStream.concat(MapStream.of(map1), MapStream.of(map2)).toMap((a, b) -> a);
            ImmutableMap <object, ? extends Number> result = MapStream.concat(MapStream.of(map1), MapStream.of(map2)).toMap((a, b) => a);

            assertThat(result).isEqualTo(ImmutableMap.of("one", 1D, "two", 2D, "three", 3D, "four", 4));
        }
        public virtual void maxValues()
        {
            KeyValuePair <string, int> result = MapStream.of(map_Renamed).maxValues(System.Collections.IComparer.naturalOrder()).get();

            assertThat(result).isEqualTo(entry("four", 4));
        }
 public virtual void noneMatch()
 {
     assertThat(MapStream.of(map_Renamed).noneMatch((key, value) => key.length() + value < 10)).False;
     assertThat(MapStream.of(map_Renamed).noneMatch((key, value) => key.length() + value < 8)).False;
     assertThat(MapStream.of(map_Renamed).noneMatch((key, value) => key.length() + value < 4)).True;
 }
        public virtual void values()
        {
            IList <int> result = MapStream.of(map_Renamed).values().collect(toImmutableList());

            assertThat(result).isEqualTo(ImmutableList.of(1, 2, 3, 4));
        }
        //-------------------------------------------------------------------------
        public virtual void keys()
        {
            IList <string> result = MapStream.of(map_Renamed).keys().collect(toImmutableList());

            assertThat(result).isEqualTo(ImmutableList.of("one", "two", "three", "four"));
        }
 //-------------------------------------------------------------------------
 public virtual void toMapDuplicateKeys()
 {
     assertThrowsIllegalArg(() => MapStream.of(map_Renamed).mapKeys(k => "key").toMap());
 }