public void Contains() { LinkedHashMap <string, Player> lhm = new LinkedHashMap <string, Player>(); Fill(lhm); Assert.IsTrue(lhm.Contains("12341")); Assert.IsFalse(lhm.Contains("55555")); }
/// <summary> /// Loads services defined in <code>services</code> and /// <code>services.ext</code> and de-dups them. /// </summary> /// <returns>List of final services to initialize.</returns> /// <exception cref="ServerException">throw if the services could not be loaded.</exception> /// <exception cref="Org.Apache.Hadoop.Lib.Server.ServerException"/> protected internal virtual IList <Service> LoadServices() { try { IDictionary <Type, Service> map = new LinkedHashMap <Type, Service>(); Type[] classes = GetConfig().GetClasses(GetPrefixedName(ConfServices)); Type[] classesExt = GetConfig().GetClasses(GetPrefixedName(ConfServicesExt)); IList <Service> list = new AList <Service>(); LoadServices(classes, list); LoadServices(classesExt, list); //removing duplicate services, strategy: last one wins foreach (Service service in list) { if (map.Contains(service.GetInterface())) { log.Debug("Replacing service [{}] implementation [{}]", service.GetInterface(), service .GetType()); } map[service.GetInterface()] = service; } list = new AList <Service>(); foreach (KeyValuePair <Type, Service> entry in map) { list.AddItem(entry.Value); } return(list); } catch (RuntimeException ex) { throw new ServerException(ServerException.ERROR.S08, ex.Message, ex); } }
public void Contains() { LinkedHashMap<string, Player> lhm = new LinkedHashMap<string, Player>(); Fill(lhm); Assert.IsTrue(lhm.Contains("12341")); Assert.IsFalse(lhm.Contains("55555")); }
public void EmptyCollectionShouldWork() { var linkedHashMap = new LinkedHashMap <int, string>(); Assert.False(linkedHashMap.Contains(new KeyValuePair <int, string>())); Assert.False(linkedHashMap.ContainsKey(0)); Assert.AreEqual(0, linkedHashMap.Count); foreach (var _ in linkedHashMap) { throw new Exception("There should be no elements."); } Assert.AreEqual(0, linkedHashMap.Keys.Count); Assert.AreEqual(0, linkedHashMap.Values.Count); }