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");
}
これはやや不器用で壊れやすいと感じます。誰もがより良い方法を知っていますか?