Пример #1
0
        public void LoadHttpDataFollowedByCancel()
        {
            var request = new HttpDataSource("https://www.google.com?q=a");
            var waiter = new AsyncWaiter();

            request.SendRequestAsync(HttpDataSource.MethodGet, HttpDataSourceResponseType.AsString);
            request.Cancel();
            request.SendRequestAsync(HttpDataSource.MethodGet, HttpDataSourceResponseType.AsString);
            Assert.AreEqual(WaiterResults.Success, waiter.Wait(10, request), "Couldn't load data");
        }
Пример #2
0
        public void TestInit()
        {
            connection = new BayeuxConnection("http://192.168.2.179:8080/cometd/");
            connection.DataReceived += LogDataReceived;
            connection.DataFailed += LogDataFailed;
            connection.ConnectionFailed += LogConnectionFailed;
            connection.Timeout = 2000;

            waiter = new AsyncWaiter();
            waiter.Reset();
        }
Пример #3
0
        public void LoadHttpData()
        {
            var request = new HttpDataSource("https://www.google.com?q=a");
            var waiter = new AsyncWaiter();
            var filter = new FilterDebugListener("Filter HttpDataSource", "Core.HttpDataSource");

            DebugLog.AddListener(filter);

            request.SendRequestAsync(HttpDataSource.MethodGet, HttpDataSourceResponseType.AsString);
            Assert.AreEqual(WaiterResults.Success, waiter.Wait(10, request), "Couldn't load data");

            Assert.AreNotEqual(0, filter.Count, "Invalid number of captured log messages!");
        }
Пример #4
0
        public void LoadHttpDataFollowedByMultipleCancel()
        {
            var request = new HttpDataSource("https://www.google.pl/search?q=a");
            var waiter = new AsyncWaiter();

            counter = 0;
            request.DataReceived += delegate { counter++; };
            request.DataReceiveFailed += delegate { counter++; };

            for (int i = 0; i < 10; i++)
            {
                request.SendRequestAsync(HttpDataSource.MethodGet, HttpDataSourceResponseType.AsString);

                waiter.Sleep(130);
                request.Cancel();
            }
            request.SendRequestAsync(HttpDataSource.MethodGet, HttpDataSourceResponseType.AsString);

            Assert.AreEqual(WaiterResults.Success, waiter.Wait(10, request), "Couldn't load data");
            Assert.AreEqual(1, counter, "Should receive data only once!");
        }