public TokenizerTest() { SimpleDictionary dict = new SimpleDictionary(); dict.Add("testing"); tokenizer = new Tokenizer(dict); }
static void Main() { // Create a dictionary that contains no more than three entries. IDictionary d = new SimpleDictionary(3); // Add three people and their ages to the dictionary. d.Add("Jeff", 40); d.Add("Kristin", 34); d.Add("Aidan", 1); Console.WriteLine("Number of elements in dictionary = {0}", d.Count); Console.WriteLine("Does dictionary contain 'Jeff'? {0}", d.Contains("Jeff")); Console.WriteLine("Jeff's age is {0}", d["Jeff"]); // Display every entry's key and value. foreach (DictionaryEntry de in d) { Console.WriteLine("{0} is {1} years old.", de.Key, de.Value); } // Remove an entry that exists. d.Remove("Jeff"); // Remove an entry that does not exist, but do not throw an exception. d.Remove("Max"); // Show the names (keys) of the people in the dictionary. foreach (String s in d.Keys) { Console.WriteLine(s); } // Show the ages (values) of the people in the dictionary. foreach (Int32 age in d.Values) { Console.WriteLine(age); } }
public ErrorModelTest() { dictionary = new SimpleDictionary(); dictionary.Add("actress"); dictionary.Add("cress"); dictionary.Add("caress"); dictionary.Add("access"); dictionary.Add("across"); dictionary.Add("acres"); errorModel = new ErrorModel(dictionary); }
public void SupportsDictionarySerialization() { var o = new SimpleDictionary(); o.Add(1, "one"); o.Add(2, "two"); o.CustomProperty = "Numbers"; var s = new FlexiXmlSerializer(); var xml = s.Serialize(o); var has_keys_element = (from e in xml.Elements() where e.Name == "Keys" select e).Any(); var has_values_element = (from e in xml.Elements() where e.Name == "Values" select e).Any(); // keys and values are skipped from serialization by default Assert.IsFalse(has_keys_element); Assert.IsFalse(has_values_element); var o2 = s.Deserialize<SimpleDictionary>(xml); Assert.IsNotNull(o2); Assert.AreNotSame(o, o2); Assert.AreEqual(o.CustomProperty, o2.CustomProperty); Assert.AreEqual(2, o2.Count); Assert.AreEqual(1, o2.Keys.First()); Assert.AreEqual("one", o2.Values.First()); Assert.AreEqual(2, o2.Keys.Skip(1).First()); Assert.AreEqual("two", o2.Values.Skip(1).First()); }
public void Add(string key, string value) { datas.Add(key, value); }