public void TestFindBy() { TVerificationResult res0, res1, res2, res3, res4, res5, res6, res7; TVerificationResultCollection coll = new TVerificationResultCollection(); res0 = new TVerificationResult(null, "test0", TResultSeverity.Resv_Noncritical); coll.Add(res0); res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical); coll.Add(res1); res2 = new TVerificationResult("stringobject2", "test2", TResultSeverity.Resv_Noncritical); coll.Add(res2); res3 = new TVerificationResult("stringobject3", "test3", TResultSeverity.Resv_Noncritical); coll.Add(res3); DataColumn col = new DataColumn("test", typeof(int)); res4 = new TScreenVerificationResult(null, col, "test4", null, TResultSeverity.Resv_Noncritical); coll.Add(res4); DataTable tab = new DataTable("test"); DataColumn col2 = new DataColumn("test2", typeof(string)); tab.Columns.Add(col2); DataColumn col3 = new DataColumn("test3", typeof(string)); tab.Columns.Add(col3); res5 = new TScreenVerificationResult(null, col2, "test5", null, TResultSeverity.Resv_Noncritical); coll.Add(res5); res6 = new TScreenVerificationResult(null, col, "test6", null, TResultSeverity.Resv_Noncritical); coll.Add(res6); res7 = new TScreenVerificationResult(null, col3, "test7", null, TResultSeverity.Resv_Noncritical); coll.Add(res7); // FindBy(index) Assert.Throws(typeof(ArgumentOutOfRangeException), delegate { coll.FindBy(20); }, "there is no verification result at index 20"); for (int i = 0; i < 8; i++) { TVerificationResult v = null; switch (i) { case 0: v = res0; break; case 1: v = res1; break; case 2: v = res2; break; case 3: v = res3; break; case 4: v = res4; break; case 5: v = res5; break; case 6: v = res6; break; case 7: v = res7; break; } Assert.AreEqual(v, coll.FindBy(i), "res" + i.ToString() + " should be at index " + i.ToString()); } // FindBy(object AResultContext) Assert.AreEqual(res2, coll.FindBy("stringobject2"), "should find res2 by resultcontext"); Assert.AreEqual(res3, coll.FindBy("stringobject3"), "should find res3 by resultcontext"); Assert.AreEqual(null, coll.FindBy("stringobject4"), "there is no verification result with resultcontext stringobject4"); Assert.AreEqual(null, coll.FindBy(null), "looking for null returns null"); // FindBy(DataColumn AResultColumn) Assert.AreEqual(res4, coll.FindBy(col), "should find res4 by column (first result with that column)"); Assert.AreEqual(res5, coll.FindBy(col2), "should find res5 by column"); Assert.AreEqual(res7, coll.FindBy(col3), "should find res7 by column"); Assert.AreEqual(null, coll.FindBy(new DataColumn("test")), "should not find an unknown column"); // FindAllBy(DataColumn AResultColumn) List <TScreenVerificationResult> result = coll.FindAllBy(col); Assert.AreEqual(2, result.Count, "FindAllBy Column should find 2 objects"); Assert.AreEqual(res4, result[0], "first object should be res4"); Assert.AreEqual(res6, result[1], "second object should be res6"); result = coll.FindAllBy(new DataColumn("test")); Assert.IsNull(result, "FindAllBy returns null for unknown column"); // FindAllBy(DataTable ADataTable) result = coll.FindAllBy(tab); Assert.AreEqual(2, result.Count, "FindAllBy Table should find 2 objects"); Assert.AreEqual(res5, result[0], "first object should be res5"); Assert.AreEqual(res7, result[1], "second object should be res7"); result = coll.FindAllBy(new DataTable("test")); Assert.IsNull(result, "FindAllBy returns null for unknown table"); }