public void op_TryAdd_string_string_whenTrue() { var obj = new KeyStringDictionary(); Assert.True(obj.TryAdd("key", "value")); Assert.Equal(1, obj.Count); }
public void op_Add_KeyStringPair() { var obj = new KeyStringDictionary { new KeyStringPair("key", "value") }; Assert.Equal(1, obj.Count); }
public void ctor_IEqualityComparerOfString() { var data = new KeyStringDictionary(StringComparer.Ordinal) { { "NAME", "value" } }; Assert.Throws <KeyNotFoundException>(() => data["name"]); }
public void op_NotContains_KeyStringPair() { var item = new KeyStringPair("key", "value"); var obj = new KeyStringDictionary { item }; Assert.False(obj.NotContains(item)); }
public void op_TryAdd_string_string_whenFalse() { var obj = new KeyStringDictionary { new KeyStringPair("key", "value") }; Assert.False(obj.TryAdd("key", "value")); Assert.Equal(1, obj.Count); }
public void op_ContainsKey_string() { var obj = new KeyStringDictionary { new KeyStringPair("key", "value") }; Assert.True(obj.ContainsKey("key")); Assert.False(obj.ContainsKey("example")); }
public void indexer_string() { var obj = new KeyStringDictionary { new KeyStringPair("A", "0"), new KeyStringPair("B", "1") }; Assert.Equal("0", obj["A"]); Assert.Equal("1", obj["B"]); }
public void op_Remove_KeyStringPair() { var item = new KeyStringPair("key", "value"); var obj = new KeyStringDictionary { item }; Assert.True(obj.Remove(item)); Assert.Equal(0, obj.Count); }
public void op_RemoveAny_strings() { var item = new KeyStringPair("key", "value"); var obj = new KeyStringDictionary { item }; obj.RemoveAny("example", "key"); Assert.Equal(0, obj.Count); }
public void op_NotEmpty_stringsEmpty(bool expected, string value) { var obj = new KeyStringDictionary { new KeyStringPair("A", value) }; var actual = obj.NotEmpty(); Assert.Equal(expected, actual); }
public void op_Length_stringsEmpty(int expected, string value) { var obj = new KeyStringDictionary { new KeyStringPair("A", value) }; var actual = obj.Length(); Assert.Equal(expected, actual); }
public void op_CloneOfT_whenKeyStringDictionary() { var obj = new KeyStringDictionary { new KeyStringPair("key", "value") }; var clone = obj.Clone <KeyStringDictionary>(); Assert.NotNull(clone); Assert.True(obj.ContainsKey("key")); Assert.False(obj.ContainsKey("example")); }
public virtual void CopyTo(KeyStringDictionary target) { if (null == target) { throw new ArgumentNullException("target"); } foreach (var item in this) { target[item.Key] = item.Value; } }
public void indexer_string_whenOutOfRange() { try { var value = new KeyStringDictionary()["A"]; Assert.True(false, value); } catch (KeyNotFoundException exception) { Assert.Equal("The 'A' key was not present in the dictionary.", exception.Message); } }
public void op_ValueOfString_string() { const string expected = "value"; var obj = new KeyStringDictionary { new KeyStringPair("key", expected) }; var actual = obj.Value <string>("key"); Assert.Equal(expected, actual); }
public void op_ValueOfDateTime_string() { var expected = DateTime.UtcNow; var obj = new KeyStringDictionary { new KeyStringPair("key", expected.ToXmlString()) }; var actual = obj.Value <DateTime>("key"); Assert.Equal(expected, actual); }
public void op_ValueOfInt32_string() { const int expected = 123; var obj = new KeyStringDictionary { new KeyStringPair("key", XmlConvert.ToString(expected)) }; var actual = obj.Value <int>("key"); Assert.Equal(expected, actual); }
public void op_CopyTo_KeyStringDictionary() { var obj = new KeyStringDictionary { new KeyStringPair("key", "value") }; var copy = new KeyStringDictionary(); obj.CopyTo(copy); Assert.True(copy.ContainsKey("key")); Assert.False(copy.ContainsKey("example")); }
public void indexer_int() { var obj = new KeyStringDictionary { new KeyStringPair("zero", "0"), new KeyStringPair("one", "1") }; for (var i = 0; i < obj.Count; i++) { Assert.Equal(XmlConvert.ToString(i), obj[i]); } }
public void op_ValueOfString_string_string(string expected, string value, string empty) { var obj = new KeyStringDictionary { new KeyStringPair("key", expected) }; var actual = obj.Value("key", empty); Assert.Equal(expected, actual); }
public void op_ValueOfInt32_int_int(int expected, string value, int empty) { var obj = new KeyStringDictionary { new KeyStringPair("key", value) }; var actual = obj.Value(0, empty); Assert.Equal(expected, actual); }
public void ctor() { const string expected = "value"; var data = new KeyStringDictionary { { "NAME", expected } }; var actual = data["name"]; Assert.Equal(expected, actual); }
public void op_GetEnumerator() { var obj = new KeyStringDictionary { new KeyStringPair("key", "value") }; foreach (var item in obj) { Assert.IsType <KeyStringPair>(item); Assert.Equal("key", item.Key); Assert.Equal("value", item.Value); } }
public void op_Strings_stringsEmpty() { var obj = new KeyStringDictionary { new KeyStringPair("A", "1"), new KeyStringPair("B", "2"), new KeyStringPair("C", "3") }; const string expected = "1,2,3"; var actual = obj.Strings().Concat(","); Assert.Equal(expected, actual); }
public void op_Set_string_string() { const string expected = "test"; var obj = new KeyStringDictionary { new KeyStringPair("Example", string.Empty) }; obj.Set("Example", expected); var actual = obj["Example"]; Assert.Equal(expected, actual); }
public void op_NotEmpty_strings(bool expected, string keys) { var obj = new KeyStringDictionary { new KeyStringPair("A", "1"), new KeyStringPair("B", string.Empty), new KeyStringPair("C", "3"), new KeyStringPair("D", string.Empty) }; var actual = obj.NotEmpty(keys.Split(',', StringSplitOptions.RemoveEmptyEntries)); Assert.Equal(expected, actual); }
public void op_Move_string_string() { var obj = new KeyStringDictionary { new KeyStringPair("A", "1"), new KeyStringPair("B", string.Empty), new KeyStringPair("C", "3") }; obj.Move("C", "B"); const string expected = "1,3,"; var actual = obj.Strings().Concat(','); Assert.Equal(expected, actual); }
public void ctor_SerializationInfo_StreamingContext() { var expected = new KeyStringDictionary { new KeyStringPair("key", "value") }; KeyStringDictionary actual; using (Stream stream = new MemoryStream()) { var formatter = new BinaryFormatter(); var obj = new KeyStringDictionary { new KeyStringPair("key", "value") }; formatter.Serialize(stream, obj); stream.Position = 0; actual = (KeyStringDictionary)formatter.Deserialize(stream); } Assert.Equal(expected, actual); }