Exemple #1
0
        public async Task ExternalWebContentSource_TestAllServers()
        {
            var urls = await ExternalWebContentSource.LoadInternalServerListAsync();

            var failedUrls = new List <Tuple <Uri, object> >();

            foreach (var url in urls)
            {
                // Make 3 attempts to successfully connect to each server.
                for (int i = 0; i < 3; i++)
                {
                    try
                    {
                        var hc     = HttpClientHelpers.Create(userAgent: UnitTestUserAgent());
                        var result = await hc.GetByteArrayAsync(url);

                        break;
                    }
                    catch (Exception ex)
                    {
                        await Task.Delay(1000);

                        if (i == 2)
                        {
                            failedUrls.Add(Tuple.Create(url, (object)ex));
                        }
                    }
                }
            }

            if (failedUrls.Any())
            {
                throw new Exception("Urls failed to GET: " + String.Join("\n", failedUrls.Select(x => x.Item1.ToString() + " - " + x.Item2.ToString())));
            }
        }
Exemple #2
0
        public void ExternalWebContentSource_ServersPerSample()
        {
            var source = new ExternalWebContentSource("", null, TimeSpan.FromMinutes(100), 20);

            Assert.AreEqual(source.ServersPerSample, 20);
        }
Exemple #3
0
        public void ExternalWebContentSource_ConfigPeriod()
        {
            var source = new ExternalWebContentSource("", null, TimeSpan.FromMinutes(100));

            Assert.AreEqual(source.PeriodNormalPriority.TotalMinutes, 100.0);
        }