Esempio n. 1
0
        public void MyTimeoutClass_SuccessfulGetLongDelay_ThrowTimeoutException()
        {
            var scheduler = new TestScheduler();
            var stub      = new SuccessHttpServiceStub2()
            {
                Scheduler = scheduler, Delay = TimeSpan.FromSeconds(1.5)
            };
            var       my     = new MyTimeOutClass(stub);
            Exception result = null;

            my.GetStringWithTimeout("http://www.example.com/", scheduler).Subscribe(_ => Assert.Fail("Received value"), ex => { result = ex; });
            scheduler.Start();
            Assert.IsInstanceOfType(result, typeof(TimeoutException));
        }
Esempio n. 2
0
        public void MyTimeoutClass_SuccessfulGetShortDelay_ReturnsResult()
        {
            var scheduler = new TestScheduler();
            var stub      = new SuccessHttpServiceStub2()
            {
                Scheduler = scheduler, Delay = TimeSpan.FromSeconds(0.5)
            };
            var    my     = new MyTimeOutClass(stub);
            string result = null;

            my.GetStringWithTimeout("http://www.example.com/", scheduler).Subscribe(r => { result = r; });
            scheduler.Start();
            Assert.AreEqual("stub", result);
        }