Exemplo n.º 1
0
        public void TestJsonWebRequestThrowsCorrectlyOnMultipleErrors([Values(true, false)] bool async)
        {
            var request = new JsonWebRequest <Drawable>("badrequest://www.google.com")
            {
                AllowInsecureRequests = true,
            };

            bool hasThrown = false;

            request.Failed += exception => hasThrown = exception != null;

            if (async)
            {
                Assert.ThrowsAsync <ArgumentException>(request.PerformAsync);
            }
            else
            {
                Assert.Throws <ArgumentException>(request.Perform);
            }

            Assert.IsTrue(request.Completed);
            Assert.IsTrue(request.Aborted);

            Assert.IsNull(request.GetResponseString());
            Assert.IsNull(request.ResponseObject);

            Assert.IsTrue(hasThrown);
        }