0

我正在进行编码的 Ui 测试。当我运行我的测试时:

 public partial class UIMap
{
    public UIMap()
    {
        this.TestInit();

    } 

    private HandlingUnitDataController huDC = new HandlingUnitDataController();
    public DataTransferHandlingUnit testHU = new DataTransferHandlingUnit();        

    public void pressEnter3()
 {    

          List<DataTransferHandlingUnit> DataList;                      


        DataList = huDC.GetHandlingUnits(null);
        foreach (DataTransferHandlingUnit hu in DataList)
        {

            if (hu.idlabel == this.IdLabelInputParams.UIScannBoxEdit2Text)
            {

                testHU = hu;
                break;
            }

        }           

        Assert.AreEqual(testHU.idlabel,this.IdLabelInputParams.UIScannBoxEdit2Text);  

        }

出现错误:

Assert.AreEqual 失败预期:<(Null)>

我做错了什么?谢谢。

4

1 回答 1

0

我的猜测是

if (hu.idlabel == this.IdLabelInputParams.UIScannBoxEdit2Text)

不评估为真,因此您的

public DataTransferHandlingUnit testHU = new DataTransferHandlingUnit();  

仍在 testHU 参考中,并且 testHU.idlabel 为空

于 2013-08-08T11:33:10.730 回答