public void FromJsonTest()
        {
            String json;

            using (StreamReader rs = new StreamReader("result.json")) {
                json = rs.ReadToEnd();
            }
            GoogleVisionApiResult res = GoogleVisionApiResult.FromJson(json);

            Debug.WriteLine(res.Responses[0].FullTextAnnotation.Text);
            Assert.IsTrue(res.Responses[0].FullTextAnnotation.Text.IndexOf("ABC") == 0);
        }
        public void ResultTest()
        {
            var task = ResultTest2();

            task.Wait();

            GoogleVisionApiResult result = task.Result;

            //Assert.IsTrue(result.Succeeded);
            Debug.WriteLine(result.Responses[0].FullTextAnnotation.Text);
            Assert.IsTrue(result.Responses[0].FullTextAnnotation.Text.IndexOf("ABC") == 0);
            Assert.AreEqual(HttpStatusCode.OK, result.HttpStatusCode);
        }
        private async Task <GoogleVisionApiResult> ResultTest2(string apikey = null)
        {
            if (apikey == null)
            {
                apikey = ApiKey;
            }

            var sess = new GoogleVisionApiSession("small.png", apikey);
            await sess.PostAsync();

            Debug.WriteLine("status={0}", new Object[] { sess.HttpResponse.StatusCode });
            GoogleVisionApiResult result = await sess.GetResult();

            return(result);
        }
        public void PostErrorTest()
        {
            var task = ResultTest2("BadKey");

            task.Wait();

            GoogleVisionApiResult result = task.Result;

            //Assert.IsFalse(result.Succeeded);
            Assert.AreNotEqual(HttpStatusCode.OK, result.HttpStatusCode);
            if (result.Error != null)
            {
                Debug.WriteLine("error code={0} status={2} message={1}",
                                new string[] { result.Error.Code, result.Error.Message, result.Error.Status });
            }
            Debug.WriteLine(result.HttpErrorMessage);
        }