public void DownloadPocketQueryIntegrationTest() { WebExtractorPocketQuery test = new WebExtractorPocketQuery(); System.Object websiteLock = new System.Object(); List <PocketQuery> queries = test.ExtractPocketQueries(websiteLock).ToList(); Assert.NotNull(queries); Assert.NotZero(queries.Count()); foreach (PocketQuery pq in queries) { Assert.NotNull(pq.DateGenerated); Assert.NotNull(pq.EntryCount); Assert.NotNull(pq.FileSize); Assert.NotNull(pq.Name); Assert.NotNull(pq.Url); Assert.NotNull(pq.HttpClient); } //Also do integration tests unzipping and file stuff. //Possibly not the ideal place to put these.. // Only need to test one link.. PocketQuery query = queries.ElementAt(0); Assert.NotNull(query.Zip); Assert.NotZero(query.Zip.Entries.Count); Assert.NotNull(query.GpxGeocaches); Assert.IsNotEmpty(query.GpxGeocaches); Assert.NotNull(query.GpxWaypoints); Assert.IsNotEmpty(query.GpxWaypoints); }
// Objects for processing and events. static void Main(string[] args) { List <PocketQuery> queries = new WebExtractorPocketQuery().ExtractPocketQueries(websiteLock).ToList(); Task[] pocketQueryTasks = new Task[queries.Count]; for (int i = 0; i < pocketQueryTasks.Length; i++) { int j = i; pocketQueryTasks[j] = Task.Factory.StartNew(() => { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["DBConnectionString"]; conn.Open(); queries[j].Save(conn); } }); } try { /* TODO: * Catch System.AggregateException and log all inner exceptions */ Task.WaitAll(pocketQueryTasks); } catch (SqlException e) { Console.WriteLine(e.ToString()); } if (Debugger.IsAttached) { Console.WriteLine("Finished, press any key (debug)"); Console.ReadKey(); } }