测试在 mxunit 中返回结构数组的函数的最佳方法是什么?现在我正在做这样的事情:
var actual = variables.pbj.getFunctions(); //returns [{name="getAccountNumber", value="0"},{name="getAccountName", value=""}]
var found = false;
//look for get account number
for(var i = 1; i lte arrayLen(actual); i ++){
if(structKeyExists(actual[i],"name") && actual[i].name eq "getAccountNumber"){
found = true;
break;
}
}
if(NOT found){
fail("Struct key getAccountNumber didn't exist");
}
found = false;
//look for account name
for(var i = 1;i lte arrayLen(actual); i ++){
if(structKeyExists(actual[i],"name") && actual[i].name eq "getAccountName"){
found = true;
break;
}
}
if(NOT found){
fail("Struct key getAccountName didn't exist");
}
这感觉有点笨拙和脆弱。有人知道更好的方法吗?