locked
Assert.AreEqual(String[] a, String[] b); Fails when visually a ==b RRS feed

  • Question

  • I am trying to compare 2 String[] arrays using Assert.AreEqual(e, a);.  As far as i can visually tell, e[] == a[]; however e.Equals(a) returns False.

    thoughts on how I can improve this test.  thanks

    List<String[][]> Signatures = new List<String[][]>();

    Signatures.Add(new String[][] { new String[] { "Sub SpecialDataLookup(wsName, _\r\n        FieldName, _\r\n        CalcRowHeading, _\r\n        ColOffset)" }, new String[] { "wsName", "FieldName", "CalcRowHeading", "ColOffset" } });

    String[] e;
    String[] a;

    foreach (String[][] s in Signatures)
    {
    e = s[1];
    a = Sa.Office.VBE_Accessor.CleanSignature(s[0][0]);

    Assert.AreEqual(e, a, "Signature: " + s[0][0]);
    }

    from the locals window

    - e {string[4]} string[]
    [0] "wsName" string
    [1] "FieldName" string
    [2] "CalcRowHeading" string
    [3] "ColOffset" string
    - a {string[4]} string[]
    [0] "wsName" string
    [1] "FieldName" string
    [2] "CalcRowHeading" string
    [3] "ColOffset" string

    Tuesday, May 15, 2012 5:14 PM

Answers

  • Hi

    Can you please check if CollectionAssert.AreEqual() helps ?

    Thanks

    • Marked as answer by Rogge Tuesday, May 15, 2012 6:36 PM
    Tuesday, May 15, 2012 6:26 PM

All replies

  • Hi

    Can you please check if CollectionAssert.AreEqual() helps ?

    Thanks

    • Marked as answer by Rogge Tuesday, May 15, 2012 6:36 PM
    Tuesday, May 15, 2012 6:26 PM
  • thanks!  that was quick and correct.
    Tuesday, May 15, 2012 6:37 PM