2

Setting up an nunit test project for some parse cloud code. Testing the hello world example cloud function I receive the following unhandled exception in Xamarin studio. (Test has passed a few times, but still receive exception)

SerializationException: Type 'Parse.ParseException' in Assembly 'Parse, Version=1.5.4.0, Culture=neutral, PublicKeyToken=ba48c3a442de616e' is not marked as serializable.

Also, mdhost.exe crashes a few seconds after the test runs.

Here is the Nunit test code.

[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);
    });
}
  • I'm running Xamarin Studio 5.9.5 (build 9) on win7
  • Copied code over to Xamarin 5.9.4 (build 5) on mac. Test runs and passes without getting mdhost.exe crash. However still showing SerializationException.
brady321
  • 1,475
  • 13
  • 14

1 Answers1

0

(Misread your question on the first answer)

Your Parse call is failing with a Parse.ParseException and that exception is what is trying to be serialized/deserialized. Wrapping a try/catch and Asserting the exception should work in order to show the error code what is actually failing in the test. (I can not get a real Parse ParseException to throw but this should get you started).

Than you can lookup the code:

[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);
    }
}
SushiHangover
  • 73,120
  • 10
  • 106
  • 165