I am using the powercollections library from http://powercollections.codeplex.com/
The first test passes, however the second test fails. I wouldn’t expect Remove to remove all items from the dictionary if a value was not found.
Is this an issue or am I misunderstanding how Remove functions ?
[Test]
public void passing_test()
{
var classes = new MultiDictionary<string, object>(false);
classes.Add("class", "class_name1");
classes.Add("class", "class_name2");
classes.Remove("class", "class_name2");
Assert.AreEqual(1, classes.Count);
}
[Test]
public void failing_test()
{
var classes = new MultiDictionary<string, object>(false);
classes.Add("class", "class_name1");
classes.Remove("class", "class_name2");
Assert.AreEqual(1, classes.Count);
}
It actually looks like a bug in the code:
Notice how they are checking for
existingCount == 1? Although the values you entered differ, there is no code to check whether the index was found in the search prior to thehash.Deletecall. The correct way to fix this would be to do something like:Here’s the full source: http://powercollections.codeplex.com/SourceControl/changeset/view/6259#71508