Assert.AreEqual failing in unit test

后端 未结 10 1355
挽巷
挽巷 2021-01-18 14:54

I have the following unit test:

string MtrlCode = \"0\";
Assessment target = new Assessment(MtrlCode);

List EdgeCaseSymbolCodes = new List<         


        
10条回答
  •  悲哀的现实
    2021-01-18 15:24

    First of all, your lists aren't the same. One has 3 elements and the other has 6, so I wouldn't expect them to be equal in the first place.

    Second, the List class only compares as equals if they're the exact same list, not just lists with the same elements. In your case you want to use something like Assert(EdgeCaseSymbolCodesExpected.SequenceEqual(target.HazardSymbols) which will walk through each element of the lists, comparing each for equality.

提交回复
热议问题