再試行、タイムアウト、失敗などの非標準的なシナリオを簡単に管理できるように、RemoteObjectをクラス内にラップしています。では、RemoteObjectを別のクラス内にラップする場合、これを単体テストするにはどうすればよいでしょうか。
クラスの使用方法の例を次に示します。
// set up the object as you would a RemoteObject, but without events:
var employeeRO: RemoteObjectWrapper = new RemoteObjectWrapper();
employeeRO.destination = "SalaryManager";
employeeRO.source = "SalaryService";
employeeRO.endpoint = "http://example.com/amf/";
// when calling the service is where you specify what to happen with results:
employeeRO
.call("getSalaries")
.register(
function onResult(salaries: Array): void
{
salaries.dataProvider = salaries;
},
function onFailure(f: *): void
{
Alert.show("Failed to fetch salaries");
});
たとえば、AdobeがRemoteObjectクラスをテストする方法について何か考えはありますか?私はサーバー側で特定のデータオブジェクトを操作していないので(私のラッパーは一般的で、RemoteObjectの使用を置き換えるように設計されています)、モッキングが答えではないと思います。またはそれは?
テストするためだけにAmfサービスを構築する必要がありますか?それとも、あなたがかけた電話を反映した、あざけるようなAmfサービスはありますか?