Problem MetadataAttribute Tests
There were a few problem tests; the first was with inserting a range, which I'm not quite sure what the problem is. I'm getting an IndexOutOfRangeException for the InsertRange statement. I'm using an index value of one, which should be a valid value with enough values. However, it's not, and so I'm going to have work with this one.
[Test()]
public void TestInsertRangeAttribute()
{
MetadataEntry testEntry = this.InitializeTest();
MetadataAttribute[] attributes = new MetadataAttribute[3];
attributes[0] = new MetadataAttribute("TestInsertRange1", "Test 1");
attributes[1] = new MetadataAttribute("TestInsertRange2", "Test 2");
attributes[2] = new MetadataAttribute("TestInsertRange3", "Test 3");
int count = testEntry.Attributes.Count;
Console.WriteLine("Count: " + count.ToString());
testEntry.Attributes.InsertRange(1, attributes);
Assert.IsTrue(testEntry.Attributes.Count == (count + 3));
Assert.AreEqual("TestInsertRange1", testEntry.Attributes[1].Name);
Assert.AreEqual("TestInsertRange2", testEntry.Attributes[2].Name);
Assert.AreEqual("TestInsertRange3", testEntry.Attributes[3].Name);
}
A problem also occurred with sorting, and so I have to recheck my sorting mechanism. It should have worked, but I get an unsorted collection. This could be something of a problem with the sorting mechanism, or maybe I misunderstood it, but looking at the sorting documentation, the approach I used appears correct according to this MSDN document: http://msdn2.microsoft.com/en-us/library/w56d4y5z.aspx. I will have to double-check this in the future.
[Test()]
public void TestSortTasks()
{
_tasks = new CollectionBase<TaskTest>();
TaskTest task = new TaskTest("A", DateTime.Today);
_tasks.Add(task);
task = new TaskTest("B", DateTime.Today);
_tasks.Add(task);
task = new TaskTest("C", DateTime.Today);
_tasks.Insert(1, task);
_tasks.Sort();
Console.WriteLine("Line 1: " + _tasks[0].Name);
Console.WriteLine("Line 2: " + _tasks[1].Name);
Console.WriteLine("Line 3: " + _tasks[2].Name);
Assert.AreEqual("A", _tasks[0].Name);
Assert.AreEqual("B", _tasks[1].Name);
Assert.AreEqual("C", _tasks[2].Name);
}
So now, the test project looks like the image attached.