in functions/testapp/Assets/Firebase/Sample/Functions/TestCase.cs [44:83]
public Task RunAsync(FirebaseFunctions functions,
Utils.Reporter reporter) {
var func = functions.GetHttpsCallable(Name);
return func.CallAsync(Input).ContinueWithOnMainThread((task) => {
if (ExpectedError == FunctionsErrorCode.None) {
// We expected no error.
if (task.IsFaulted) {
// The function unexpectedly failed.
throw task.Exception;
}
// The function succeeded.
if (!Utils.DeepEquals(ExpectedData, task.Result.Data, reporter)) {
throw new Exception(String.Format("Incorrect result. Got {0}. Want {1}.",
Utils.DebugString(task.Result.Data),
Utils.DebugString(ExpectedData)));
}
return;
}
// The function was expected to fail.
FunctionsException e = null;
foreach (var inner in task.Exception.InnerExceptions) {
if (inner is FunctionsException) {
e = (FunctionsException)inner;
break;
}
}
if (e == null) {
// We didn't get a proper Functions Exception.
throw task.Exception;
}
if (e.ErrorCode != ExpectedError) {
// The code wasn't right.
throw new Exception(String.Format("Error {0}: {1}", e.ErrorCode, e.Message));
}
reporter(String.Format(" Got expected error {0}: {1}", e.ErrorCode,
e.Message));
});
}