为某些解析云代码设置nunit测试项目。测试hello world示例云函数我在Xamarin工作室中收到以下未处理的异常。 (测试已经过了几次,但仍然收到异常)
SerializationException:在Assembly'Parse,Version = 1.5.4.0,Culture = neutral,PublicKeyToken = ba48c3a442de616e'中输入'Parse.ParseException'未标记为可序列化。
此外,测试运行后几秒钟mdhost.exe崩溃。
这是Nunit测试代码。
[Test()]
public async void HelloTest(){
IDictionary<string, object> param = new Dictionary<string, object> ();
await ParseCloud.CallFunctionAsync<string>("hello",param).ContinueWith(t => {
string resp = t.Result;
Assert.AreEqual("Hello world!", resp);
});
}
答案 0 :(得分:0)
(在第一个答案中误读了你的问题)
您的Parse调用失败并出现Parse.ParseException,并且该异常是尝试序列化/反序列化的内容。包装try / catch并断言异常应该有效,以便显示错误代码测试中实际失败的内容。 (我无法获得真正的Parse ParseException,但这应该让你开始)。
您可以查找http://www.eclipse.org/eclipselink/xsds/persistence/orm:
[Test ()]
public async void HelloTest ()
{
IDictionary<string, object> param = new Dictionary<string, object> ();
try {
await ParseCloud.CallFunctionAsync<string> ("hello", param).ContinueWith (t => {
string resp = t.Result;
Assert.AreEqual ("Hello world!", resp);
});
} catch (ParseException ex) {
Assert.Fail (String.Format("{0} : {1}", ex.Code, ex.Message));
} catch (Exception ex) {
Assert.Fail (ex.Message);
}
}