public void TestRemove() { TVerificationResult res0, res1, 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); 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); Assert.AreEqual(6, coll.Count, "should be 6 elements at the start of the test"); // Remove(DataColumn) coll.Remove(col); Assert.AreEqual(5, coll.Count, "only one element should be removed, even if there are 2 results with column col"); Assert.AreEqual(2, coll.IndexOf(res5), "res4 was removed"); coll.Insert(2, res4); coll.Remove(new DataColumn("test")); Assert.AreEqual(6, coll.Count, "nothing happens when trying to remove unknown column"); // Remove(IResultInterface value) coll.Remove(res1); Assert.AreEqual(5, coll.Count, "res1 should have been removed"); coll.Insert(1, res1); Assert.Throws(typeof(ArgumentException), delegate { coll.Remove(new TVerificationResult(null, "test3", TResultSeverity.Resv_Info)); }, "trying to remove unknown verification result throws ArgumentException"); // Remove(String AResultColumnName) coll.Remove("nonexisting"); Assert.AreEqual(6, coll.Count, "nothing happens when trying to remove unknown resultcolumnname"); coll.Remove(col.ColumnName); Assert.AreEqual(5, coll.Count, "should have removed res4"); Assert.AreEqual(res6, coll.FindBy(col), "first result with col should be res6"); coll.Insert(4, res4); }
public void TestInsertAndIndexOf() { TVerificationResult res0, res1, res2, res3, res4; TVerificationResultCollection coll = new TVerificationResultCollection(); // insert in the middle res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical); coll.Add(res1); res3 = new TVerificationResult(null, "test3", TResultSeverity.Resv_Noncritical); coll.Add(res3); Assert.AreEqual(0, coll.IndexOf(res1), "res1 should be at position 0"); Assert.AreEqual(1, coll.IndexOf(res3), "res3 should be at position 1"); res2 = new TVerificationResult(null, "test2", TResultSeverity.Resv_Noncritical); coll.Insert(1, res2); Assert.AreEqual(0, coll.IndexOf(res1), "res1 should be at position 0"); Assert.AreEqual(1, coll.IndexOf(res2), "res2 should be at position 1"); Assert.AreEqual(2, coll.IndexOf(res3), "res3 should be at position 2"); // insert at the front res0 = new TVerificationResult(null, "test0", TResultSeverity.Resv_Noncritical); coll.Insert(0, res0); Assert.AreEqual(0, coll.IndexOf(res0), "res0 should be at position 0"); Assert.AreEqual(1, coll.IndexOf(res1), "res1 should be at position 1"); Assert.AreEqual(2, coll.IndexOf(res2), "res2 should be at position 2"); Assert.AreEqual(3, coll.IndexOf(res3), "res3 should be at position 3"); // insert at the back res4 = new TVerificationResult(null, "test4", TResultSeverity.Resv_Noncritical); coll.Insert(4, res4); Assert.AreEqual(0, coll.IndexOf(res0), "res0 should be at position 0"); Assert.AreEqual(1, coll.IndexOf(res1), "res1 should be at position 1"); Assert.AreEqual(2, coll.IndexOf(res2), "res2 should be at position 2"); Assert.AreEqual(3, coll.IndexOf(res3), "res3 should be at position 3"); Assert.AreEqual(4, coll.IndexOf(res4), "res4 should be at position 4"); }