public static void Main(string[] args) { var conn = new MySqlConnection("server=localhost;user=yelp_etl;password=P@ssword!;port=3306;"); Console.WriteLine("Creating database: yelp..."); try { DropDatabaseIfExist(conn); conn.Open(); conn.Execute(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "data", "yelp_db.sql"))); } finally { conn.Close(); } Console.WriteLine("Database created."); try { Console.WriteLine("Starting load..."); //Long running task should start first var t1 = Task.Run(() => BusinessLoader.Load(Helpers.CreateConnectionToYelpDb())); var t2 = Task.Run(() => ReviewLoader.Load(Helpers.CreateConnectionToYelpDb())); //Faster loaders can run sequencially CheckinLoader.Load(Helpers.CreateConnectionToYelpDb()); TipLoader.Load(Helpers.CreateConnectionToYelpDb()); UserLoader.Load(Helpers.CreateConnectionToYelpDb()); Task.WaitAll(t1, t2); Console.WriteLine("Load complete."); } catch (AggregateException aEx) { Console.WriteLine("Load Failure."); foreach (var ex in aEx.Flatten().InnerExceptions) { Console.WriteLine(ex.Message); } throw; } catch (Exception ex) { Console.WriteLine($"Load Failure: {ex.Message}."); DropDatabaseIfExist(conn); } conn.Dispose(); Console.WriteLine("Press any key to exit."); Console.ReadLine(); }
// try to load tip from resources public void TipLoaderFromResources() { // unset current tip if exists and create game object with TipLoader tip = null; GameObject tipLoaderGameObject = new GameObject("Test tip loader"); TipLoader tipLoader = tipLoaderGameObject.AddComponent <TipLoader>(); // tip loaded event TipLoader.OnTipLoaded += TipLoaded; // load tip tipLoader.Load(); // if tip is not null, the test succeeded Assert.IsNotNull(tip); TipLoader.OnTipLoaded -= TipLoaded; }
// try to load tip from web public IEnumerator TipLoaderFromWeb() { // unset current tip if exists and create game object with TipLoader tip = null; GameObject tipLoaderGameObject = new GameObject("Test tip loader"); TipLoader tipLoader = tipLoaderGameObject.AddComponent <TipLoader>(); // load from web tipLoader.loadFromWeb = true; tipLoader.url = "davand.net/app.php"; // tip loaded event TipLoader.OnTipLoaded += TipLoaded; // load tip tipLoader.Load(); // wait few seconds while tip loads yield return(new WaitForSeconds(3)); // if tip is not null, the test succeeded Assert.IsNotNull(tip); }