Esempio n. 1
0
        public void TestTimeoutFailsAfterLongDelay()
        {
            var scheduler = new TestScheduler();
            var stub      = new SuccessHttpServiceStub()
            {
                Scheduler = scheduler,
                Delay     = TimeSpan.FromHours(5)
            };

            var       sut    = new Timeout(stub);
            Exception result = null;

            sut.GetStringWithTimeout("www.amazon.com", scheduler)
            .Subscribe(_ => Assert.True(false), error => result = error);

            scheduler.Start();
            Assert.IsType <TimeoutException>(result);
        }
Esempio n. 2
0
        public void TestTimeoutReturnsAfterDelay()
        {
            var scheduler = new TestScheduler();
            var stub      = new SuccessHttpServiceStub()
            {
                Scheduler = scheduler,
                Delay     = TimeSpan.FromMilliseconds(1)
            };

            var    sut    = new Timeout(stub);
            string result = "Failure";

            sut.GetStringWithTimeout("www.amazon.com", scheduler)
            .Subscribe(data => result = data);

            scheduler.Start();
            Assert.Equal("Success", result);
        }