//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateValuesIfMissing() public virtual void ShouldCreateValuesIfMissing() { // GIVEN IDictionary <string, AtomicLong> map = new AutoCreatingHashMap <string, AtomicLong>(values(typeof(AtomicLong))); string key = "should be created"; // WHEN map[key].incrementAndGet(); // THEN assertEquals(1, map[key].get()); assertTrue(map.ContainsKey(key)); assertFalse(map.ContainsKey("any other key")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateValuesEvenForNestedMaps() public virtual void ShouldCreateValuesEvenForNestedMaps() { // GIVEN IDictionary <string, IDictionary <string, IDictionary <string, AtomicLong> > > map = new AutoCreatingHashMap <string, IDictionary <string, IDictionary <string, AtomicLong> > >(nested(typeof(string), nested(typeof(string), values(typeof(AtomicLong))))); string keyLevelOne = "first"; string keyLevelTwo = "second"; string keyLevelThree = "third"; // WHEN map[keyLevelOne][keyLevelTwo][keyLevelThree].addAndGet(10); // THEN assertTrue(map.ContainsKey(keyLevelOne)); assertFalse(map.ContainsKey(keyLevelTwo)); // or any other value for that matter IDictionary <string, IDictionary <string, AtomicLong> > levelOne = map[keyLevelOne]; assertTrue(levelOne.ContainsKey(keyLevelTwo)); assertFalse(levelOne.ContainsKey(keyLevelThree)); // or any other value for that matter IDictionary <string, AtomicLong> levelTwo = levelOne[keyLevelTwo]; assertTrue(levelTwo.ContainsKey(keyLevelThree)); assertFalse(levelTwo.ContainsKey(keyLevelOne)); // or any other value for that matter AtomicLong levelThree = levelTwo[keyLevelThree]; assertEquals(10, levelThree.get()); }