public void ContainsKeyTest() { CLArguments containsList = this.Template.Clone(); Assert.IsTrue(containsList.ContainsKey(KEY), "List does not contains existing key"); Assert.IsFalse(containsList.ContainsKey(VALUE), "List contains existing value as key"); Assert.IsFalse(containsList.ContainsKey(NOT_EXIST_KEY), "List contains non-existing key"); Assert.IsFalse(containsList.ContainsKey(NOT_EXIST_VALUE), "List contains non-existing value as key"); }
public void AddTest() { const string TO_LAST_KEY = "value_to_the_last_key"; const string ADDED_LONE_KEY = "-added_lone_key"; const string ADDED_TO_EXISTING_VALUE = "added_to_existing_value"; const string ADDED_WITH_VALUE_KEY = "-added_with_value_key"; const string ADDED_TO_MISSING_KEY = "added_to_missing_key"; CLArguments addList = this.Template.Clone(); string lastKey = CLArguments.NO_KEY; for (int i = addList.Count - 1; i >= 0; i--) { if (addList.IsKey(addList[i])) { lastKey = addList[i]; break; } } addList.Add(TO_LAST_KEY); Assert.AreEqual(TO_LAST_KEY, addList[addList.Count - 1], "Last item in list wasn't the added value"); string[] lastValues = addList[lastKey]; Assert.AreEqual(TO_LAST_KEY, lastValues[lastValues.Length - 1], "Last item in last key's values list wasn't teh added value"); addList.Add(ADDED_LONE_KEY); Assert.AreEqual(ADDED_LONE_KEY, addList[addList.Count - 1], "Last item isn't the added key"); Assert.IsTrue(addList.IsKey(addList[addList.Count - 1]), "Last key isn't considered as a key"); addList.Add(ADDED_LONE_KEY, ADDED_TO_EXISTING_VALUE); Assert.IsTrue(addList[ADDED_LONE_KEY].Any(), "Existing key doesn't contain values"); Assert.AreEqual(ADDED_TO_EXISTING_VALUE, addList[ADDED_LONE_KEY][addList[ADDED_LONE_KEY].Length - 1], "Last value of existing key is invalid"); addList.Add(ADDED_WITH_VALUE_KEY, ADDED_TO_MISSING_KEY); Assert.IsTrue(addList.ContainsKey(ADDED_WITH_VALUE_KEY), "New key doesn't exist"); Assert.IsTrue(addList[ADDED_WITH_VALUE_KEY].Length == 1, "New key have incorrent number of values"); Assert.AreEqual(ADDED_TO_MISSING_KEY, addList[ADDED_WITH_VALUE_KEY][0], "New key doesn't contains the correct value"); }
public void IndexerSetTest() { const string NEW_VALUE = "new_value"; CLArguments indexerList = this.Template.Clone(); var valuesArr = new string[] { NEW_VALUE }; indexerList[KEY] = valuesArr; Assert.IsTrue(indexerList[KEY].SequenceEqual(valuesArr), "Failed to set existing key"); var notExistValueArr = new string[] { NOT_EXIST_VALUE }; indexerList[NOT_EXIST_KEY] = notExistValueArr; Assert.IsTrue(indexerList.ContainsKey(NOT_EXIST_KEY), "Failed to create new key in set"); Assert.IsTrue(indexerList[NOT_EXIST_KEY].SequenceEqual(notExistValueArr), "Failed to create values for key"); }