public static void AssertEquals(string id, TestPart expected, TestPart ob) { if (!AssertionHelper.AssertType(id, expected, ob)) { return; } Assertion.AssertEquals(id + " name", expected.name, ob.name); Assertion.AssertEquals(id + " bval", expected.bval, ob.bval); }
void CheckParts(string id, TestPart[] exp, TestPart[] parts) { AssertionHelper.AssertType(id, exp, parts); AssertEquals(id + " Len", exp.Length, parts.Length); for (int n = 0; n < exp.Length; n++) { TestPart.AssertEquals(id + "[" + n + "]", exp[n], parts[n]); } }
public static void AssertEquals (string id, TestPart expected, TestPart ob) { if (!AssertionHelper.AssertType (id, expected, ob)) return; Assert.AreEqual (expected.name, ob.name, id + " name"); Assert.AreEqual (expected.bval, ob.bval, id + " bval"); }
void CheckObjectContent(Test exp, Test t) { AssertEquals("t.a", exp.a, t.a); AssertEquals("t.b", exp.b, t.b); AssertEquals("t.bbis", exp.bbis, t.bbis); AssertEquals("t.c", exp.c, t.c); AssertNotNull("t.parts", t.parts); CheckParts("t.parts", exp.parts, t.parts); TestPart.AssertEquals("t.part", exp.part, t.part); AssertionHelper.AssertEqualsArray("t.strings", exp.strings, t.strings); AssertionHelper.AssertEqualsArray("t.ushorts", exp.ushorts, t.ushorts); TA.AssertEquals("t.ta", exp.ta, t.ta); AssertNotNull("t.tam2", t.tam2); CheckTaArray("t.tam2", exp.tam2, t.tam2); AssertNotNull("t.tam3", t.tam3); CheckTaArray("t.tam3", exp.tam3, t.tam3); AssertNotNull("t.flatParts", t.flatParts); CheckParts("t.flatParts", exp.flatParts, t.flatParts); // Null element is ignored AssertNotNull("t.flatParts2", t.flatParts2); AssertEquals("t.flatParts2.Length", 3, t.flatParts2.Length); TA.AssertEquals("t.flatParts2 0", exp.flatParts2[0], t.flatParts2[0]); TA.AssertEquals("t.flatParts2 1", exp.flatParts2[1], t.flatParts2[1]); TA.AssertEquals("t.flatParts2 2", exp.flatParts2[3], t.flatParts2[2]); AssertNotNull("t.anot", t.anot); AssertEquals("t.anot.lo", ((AnotherTestPart)exp.anot).lo, ((AnotherTestPart)t.anot).lo); TestPart.AssertEquals("t.ob", exp.ob as TestPart, t.ob as TestPart); TestPart.AssertEquals("t.ob2", exp.ob2 as TestPart, t.ob2 as TestPart); AssertionHelper.AssertEqualsXml("t.oneElem", exp.oneElem, t.oneElem); AssertionHelper.AssertEqualsXml("t.oneElem2", exp.oneElem2, t.oneElem2); // One of the elements was null and it is ignored AssertNotNull("t.someElems", t.someElems); AssertEquals("t.someElems.Length", 2, t.someElems.Length); AssertionHelper.AssertEqualsXml("t.someElems[0]", exp.someElems[0], t.someElems[0]); AssertionHelper.AssertEqualsXml("t.someElems[1]", exp.someElems[2], t.someElems[1]); AssertNotNull("t.extraElems", t.extraElems); AssertEquals("t.extraElems.Length", exp.extraElems.Length, t.extraElems.Length); for (int n = 0; n < exp.extraElems.Length; n++) { AssertionHelper.AssertEqualsXml("t.extraElems[" + n + "]", exp.extraElems[n], t.extraElems[n]); } AssertNotNull("t.extraElems23", t.extraElems23); AssertEquals("t.extraElems23.Length", exp.extraElems23.Length, t.extraElems23.Length); for (int n = 0; n < t.extraElems23.Length; n++) { AssertionHelper.AssertEqualsXml("t.extraElems23[" + n + "]", exp.extraElems23[n], t.extraElems23[n]); } AssertionHelper.AssertEqualsXml("t.extraElemsRest", exp.extraElemsRest, t.extraElemsRest); UnknownAttributeTester.AssertEquals("t.uktester", exp.uktester, t.uktester); AssertEquals("t.ob3", exp.ob3, t.ob3); AssertEquals("t.ob4", exp.ob4, t.ob4); AssertEquals("t.op1", exp.op1, t.op1); AssertionHelper.AssertEqualsArray("t.opArray", exp.opArray, t.opArray); AssertEquals("t.ukOpt", exp.ukOpt, t.ukOpt); AssertEquals("t.opAtt", exp.opAtt, t.opAtt); AssertionHelper.AssertEqualsArray("t.byteArray", exp.byteArray, t.byteArray); AssertionHelper.AssertEqualsArray("t.byteByteArray", exp.byteByteArray, t.byteByteArray); AssertNotNull("t.ttList", t.ttList); AssertionHelper.AssertEqualsArray("t.ttList", exp.ttList.ToArray(), t.ttList.ToArray()); AssertNotNull("t.RoList", t.RoList); AssertEquals("t.RoList.Count", exp.RoList.Count, t.RoList.Count); for (int n = 0; n < exp.RoList.Count; n++) { TestPart.AssertEquals("t.RoList " + n, (TestPart)exp.RoList[n], (TestPart)t.RoList[n]); } AssertEquals("t.struc.aa", exp.struc.aa, t.struc.aa); AssertEquals("t.struc.cc", exp.struc.cc, t.struc.cc); AssertNotNull("t.multiList", t.multiList); AssertEquals("t.multiList.Count", exp.multiList.Length, t.multiList.Length); for (int n = 0; n < exp.multiList.Length; n++) { AssertionHelper.AssertEqualsArray("t.multiList " + n, exp.multiList[n].ToArray(), t.multiList[n].ToArray()); } AssertEquals("t.defElem", exp.defElem, t.defElem); AssertEquals("t.defAttr", exp.defAttr, t.defAttr); CustomHashtable.AssertEquals("t.special", exp.special, t.special); AssertEquals("t.attqname", exp.attqname, t.attqname); AssertNotNull("t.dbscontainer", t.dbscontainer); DblStringContainer tdbca = t.dbscontainer.at as DblStringContainer; DblStringContainer expdbca = exp.dbscontainer.at as DblStringContainer; AssertNotNull("t.dbscontainer.at", tdbca); AssertNotNull("t.dbscontainer.dbca", tdbca); AssertionHelper.AssertEqualsArray("t.dbscontainer.at.doublestring", expdbca.doublestring, tdbca.doublestring); AnotherTestPart tat = tdbca.at as AnotherTestPart; AnotherTestPart expat = expdbca.at as AnotherTestPart; AssertNotNull("t.dbscontainer.dbca.at", tat); AssertEquals("t.dbscontainer.dbca.at.lo", expat.lo, tat.lo); }
void CheckParts (string id, TestPart[] exp, TestPart[] parts) { AssertionHelper.AssertType (id, exp, parts); Assert.AreEqual (exp.Length, parts.Length, id + " Len"); for (int n=0; n<exp.Length; n++) TestPart.AssertEquals (id + "[" + n + "]", exp[n], parts[n]); }