Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariableMapCompatibility()
        public virtual void testVariableMapCompatibility()
        {
            // test compatibility with Map<String, Object>
            VariableMap map1 = createVariables().putValue("foo", 10).putValue("bar", 20);

            // assert the map is assignable to Map<String,Object>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unused") java.util.Map<String, Object> assignable = map1;
            IDictionary <string, object> assignable = map1;

            VariableMap map2 = createVariables().putValueTyped("foo", integerValue(10)).putValueTyped("bar", integerValue(20));

            IDictionary <string, object> map3 = new Dictionary <string, object>();

            map3["foo"] = 10;
            map3["bar"] = 20;

            // equals()
            assertEquals(map1, map2);
            assertEquals(map2, map3);
            assertEquals(map1, fromMap(map1));
            assertEquals(map1, fromMap(map3));

            // hashCode()
            assertEquals(map1.GetHashCode(), map2.GetHashCode());
            assertEquals(map2.GetHashCode(), map3.GetHashCode());

            // values()
            VariableMap.ValueCollection values1 = map1.Values;
            VariableMap.ValueCollection values2 = map2.Values;
            IDictionary <string, object> .ValueCollection values3 = map3.Values;
            assertTrue(values1.containsAll(values2));
            assertTrue(values2.containsAll(values1));
            assertTrue(values2.containsAll(values3));
            assertTrue(values3.containsAll(values2));

            // entry set
            assertEquals(map1.SetOfKeyValuePairs(), map2.SetOfKeyValuePairs());
            assertEquals(map2.SetOfKeyValuePairs(), map3.SetOfKeyValuePairs());
        }