public void ShouldBeAbleToRestore() { SQLiteDatabase toBackup = GetTestDatabase(MethodBase.GetCurrentMethod().Name); toBackup.MaxConnections = 500; FillDatabaseWithTestData(toBackup); MainObjectCollection main = MainObject.LoadAll(toBackup); SecondaryObjectCollection secondary = SecondaryObject.LoadAll(toBackup); TernaryObjectCollection ternary = TernaryObject.LoadAll(toBackup); List <IRepository> repos = new List <IRepository>(); repos.Add(new DaoRepository(new SQLiteDatabase("BackupRepo_{0}"._Format(MethodBase.GetCurrentMethod().Name), "BackupRepoDb"))); repos.Add(new ObjectRepository("ObjectRepo_{0}"._Format(MethodBase.GetCurrentMethod().Name))); foreach (IRepository repo in repos) { DaoBackup backup = new DaoBackup(typeof(MainObject).Assembly, toBackup, repo); backup.Backup(); SQLiteDatabase restored = GetTestDatabase("{0}_Restored_For_{1}"._Format(MethodBase.GetCurrentMethod().Name, repo.GetType().Name)); HashSet <OldToNewIdMapping> restoreInfo = backup.Restore(restored); List <string> keys = restoreInfo.Select(i => i.Uuid).ToList(); main.Each(new { Uuids = keys }, (ctx, m) => { Expect.IsTrue(ctx.Uuids.Contains(m.Uuid)); }); secondary.Each(new { Uuids = keys }, (ctx, s) => { Expect.IsTrue(ctx.Uuids.Contains(s.Uuid)); }); ternary.Each(new { Uuids = keys }, (ctx, t) => { Expect.IsTrue(ctx.Uuids.Contains(t.Uuid)); }); restoreInfo.Each(ri => { OutLineFormat(ri.PropertiesToString(), ConsoleColor.DarkYellow); }); OutLineFormat("Repository of type {0} passed restore test", ConsoleColor.Green, repo.GetType().Name); } }
/// <summary> /// This method is intended to respond to client side Qi queries. /// Use of this method from .Net should be avoided in favor of /// one of the methods that take a delegate of type /// WhereDelegate<TernaryObjectColumns>. /// </summary> /// <param name="where"></param> /// <param name="database"></param> public static TernaryObjectCollection Where(QiQuery where, Database database = null) { var results = new TernaryObjectCollection(database, Select <TernaryObjectColumns> .From <TernaryObject>().Where(where, database)); return(results); }