public void CallOnErrorIfError()
        {
            // arrange
            var uri = "http://localhost/";
            var factory = new TestWebRequestFactory();
            factory.RegisterExceptionForUri<WebException>(uri);
            var handler = new TestBaseRequestHandler(factory);

            // act
            var data = new object();
            handler.MakeRequest(uri, null, (exuri, exception) => data = exception);

            // assert
            Assert.IsNotNull(data);
        }
        public void CallOnSuccessIfNoError()
        {
            // arrange
            var uri = "http://localhost/";
            var factory = new TestWebRequestFactory();
            factory.RegisterResultForUri(uri, "null");
            var handler = new TestBaseRequestHandler(factory);

            // act
            var data = new object();
            handler.MakeRequest(uri, (code, location, response) => data = response, null);

            // assert
            Assert.IsNull(data);
        }
        public void CanExtractJsonEntity()
        {
            // arrange
            var uri = "http://localhost/";
            var factory = new TestWebRequestFactory();
            factory.RegisterResultForUri(uri, "{ \"Name\": \"Paul\" }");
            var handler = new TestBaseRequestHandler(factory);

            // act
            UserContract data = null;
            handler.MakeRequest(uri, (code, location, response) => data = response, null);

            // assert
            Assert.IsNotNull(data);
            Assert.AreEqual("Paul", data.Name);
        }
Esempio n. 4
0
        public void CallOnErrorIfError()
        {
            // arrange
            var uri     = "http://localhost/";
            var factory = new TestWebRequestFactory();

            factory.RegisterExceptionForUri <WebException>(uri);
            var handler = new TestBaseRequestHandler(factory);

            // act
            var data = new object();

            handler.MakeRequest(uri, null, (exuri, exception) => data = exception);

            // assert
            Assert.IsNotNull(data);
        }
Esempio n. 5
0
        public void CallOnSuccessIfNoError()
        {
            // arrange
            var uri     = "http://localhost/";
            var factory = new TestWebRequestFactory();

            factory.RegisterResultForUri(uri, "null");
            var handler = new TestBaseRequestHandler(factory);

            // act
            var data = new object();

            handler.MakeRequest(uri, (code, location, response) => data = response, null);

            // assert
            Assert.IsNull(data);
        }
Esempio n. 6
0
        public void CanExtractCompressedJsonEntity()
        {
            // arrange
            var uri     = "http://localhost/";
            var factory = new TestWebRequestFactory();

            factory.RegisterCompressedResultForUri(uri, "{ \"Name\": \"Paul\" }");
            var handler = new TestBaseRequestHandler(factory);

            // act
            UserContract data = null;

            handler.MakeRequest(uri, (code, location, response) => data = response, null);

            // assert
            Assert.IsNotNull(data);
            Assert.AreEqual("Paul", data.Name);
        }