예제 #1
0
        public async Task GetPublicIp_should_tolerate_echo_failure()
        {
            var echoUrlWithFailure = new[] { "https://this.will.fail.for.sure" }
            .Concat(Ip.DefaultIpEchoUrls).ToObservable();
            var myIp = await Ip.GetPublicIpAsync(echoUrlWithFailure);

            myIp.Should().NotBe(default(IPAddress));
        }
예제 #2
0
        public async Task GetPublicIp_should_not_wait_for_longest_response()
        {
            var delayedObservable = Ip.DefaultIpEchoUrls
                                    .Select((o, i) =>
            {
                return(i != 2
                        ? Observable.Timer(TimeSpan.FromSeconds(5)).Select(_ => o)
                        : Observable.Return(o));
            }).Merge();

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var myIp = await Ip.GetPublicIpAsync(delayedObservable);

            stopWatch.Stop();

            myIp.Should().NotBe(default(IPAddress));
            stopWatch.Elapsed.Should().BeLessThan(TimeSpan.FromSeconds(3));
        }
예제 #3
0
        public async Task GetPublicIp_should_usually_return_a_valid_ip()
        {
            var myIp = await Ip.GetPublicIpAsync();

            myIp.Should().NotBe(default(IPAddress));
        }