private void TestDictionary(Dictionaries.Keys key) { var dict = Dictionaries.Get(key); Assert.IsNotNull(dict, String.Format("Dictionary {0} is null", key)); Assert.IsInstanceOfType(dict, typeof(string[]), String.Format("Dictionary {0} is not a string array", key)); int expectedLength = GetExpectedLength(key); Assert.AreEqual(expectedLength, dict.Length, String.Format("Dictionary {0} has wrong length", key)); }
public void Get() { //given var src = new Dictionary <string, string> { { "one", "1" }, { "two", "2" } }; //then Assert.Equal(Dictionaries.Get(src, "one"), "1"); Assert.Equal(Dictionaries.Get(src, "two"), "2"); Assert.Null(Dictionaries.Get(src, "three")); }
public void Get() { //given var src = new Dictionary <string, object> { { "one", "1" }, { "two", 2 }, { "four", new double[] { 4.1, 4.2, 4.3 } } }; //then Assert.That(Dictionaries.Get <string>(src, "one"), Is.EqualTo("1")); Assert.That(Dictionaries.Get <int>(src, "two"), Is.EqualTo(2)); Assert.That(Dictionaries.Get <double[]>(src, "four"), Is.EqualTo(new double[] { 4.1, 4.2, 4.3 })); Assert.Null(Dictionaries.Get <string>(src, "three")); Assert.Null(Dictionaries.Get <string>(null, "one")); }