public void LoadAndRestoreCurrentRuntimeTestAsync() { AssemblyServiceRepository assManRepo = GetTestRepo(nameof(LoadAndRestoreCurrentRuntimeTestAsync)); DaoRepository fileRepo = new DaoRepository() { Database = assManRepo.Database }; fileRepo.AddTypes(typeof(ChunkedFileDescriptor), typeof(ChunkDataDescriptor), typeof(ChunkData)); fileRepo.EnsureDaoAssemblyAndSchema(); FileService fmSvc = new FileService(fileRepo); AssemblyService svc = new AssemblyService(DataSettings.Current, fmSvc, assManRepo, DefaultConfigurationApplicationNameProvider.Instance); ProcessRuntimeDescriptor prd1 = svc.CurrentProcessRuntimeDescriptor; ProcessRuntimeDescriptor prd2 = svc.CurrentProcessRuntimeDescriptor; ProcessRuntimeDescriptor byName = assManRepo.OneProcessRuntimeDescriptorWhere(c => c.ApplicationName == prd1.ApplicationName); OutLineFormat("AppName: {0}", ConsoleColor.Cyan, prd1.ApplicationName); Expect.AreEqual(prd1.Cuid, prd2.Cuid); Expect.AreEqual(prd1.Cuid, byName.Cuid); bool?fired = false; svc.RuntimeRestored += (o, a) => { fired = true; OutLine(((ProcessRuntimeDescriptorEventArgs)a).DirectoryPath); }; svc.RestoreApplicationRuntime(byName.ApplicationName, $".\\{nameof(LoadAndRestoreCurrentRuntimeTestAsync)}"); Expect.IsTrue(fired.Value); }
public void RepoShouldBeQueryable() { DaoRepository repo = GetTestDaoRepository(); repo.EnsureDaoAssemblyAndSchema(); House one = new House { Name = "Get This One" }; House two = new House { Name = "Get This Too" }; House three = new House { Name = "Not this one" }; repo.Save(one); repo.Save(three); repo.Save(two); House[] houses = repo.Query <House>(Query.Where("Name").StartsWith("Get")).ToArray(); Expect.AreEqual(2, houses.Length); houses.Each(house => { repo.Delete(house); }); repo.Delete(three); }
public void ShouldBeAbleToReflectOverGeneratedDaoAssembly() { DaoRepository daoRepo = GetTestDaoRepository(); Assembly daoAssembly = daoRepo.EnsureDaoAssemblyAndSchema(); Type[] types = daoAssembly.GetTypes(); foreach (Type type in types) { OutLineFormat("{0}", type.FullName); } Type daoType = daoAssembly.GetType("TypeDaos.Dao.TestContainer"); Expect.IsNotNull(daoType); }
public void ParentSaveShouldSaveChildren() { DaoRepository repo = GetTestDaoRepository(); repo.EnsureDaoAssemblyAndSchema(); Parent parent = new Parent(); parent.Name = "Parent Name"; Son sonOne = new Son(); Son sonTwo = new Son(); parent.Sons = new List <Son>(new Son[] { sonOne, sonTwo }); parent = repo.Save(parent); Parent retrieved = repo.Retrieve <Parent>(parent.Id); Expect.AreEqual(2, retrieved.Sons.Count); }
public void RetrieveShouldSetParentOnChildren() { DaoRepository repo = GetTestDaoRepository(); repo.EnsureDaoAssemblyAndSchema(); Parent parent = new Parent(); parent.Name = "Test parent"; Son one = new Son(); one.Name = "Son"; parent.Sons = new List <Son>(new Son[] { one }); parent = repo.Save(parent); Son checkSon = repo.Retrieve <Son>(parent.Sons[0].Id); Expect.AreEqual(one.Name, checkSon.Name); Expect.AreEqual(parent.Id, checkSon.Parent.Id); Expect.AreEqual(parent.Name, checkSon.Parent.Name); }
public void SavingParentShouldSaveChildLists() { DaoRepository repo = GetTestDaoRepository(); repo.EnsureDaoAssemblyAndSchema(); House house = new House { Name = "TestHouse", Parents = new List <Parent> { new Parent { Name = "TestParent" } } }; repo.Save(house); House retrieved = repo.Retrieve <House>(house.Id); Expect.AreEqual(1, retrieved.Parents.Count); }
public void SavingParentXrefShouldSetChildXref() { DaoRepository repo = GetTestDaoRepository(); repo.EnsureDaoAssemblyAndSchema(); House house = new House { Name = "TestHouse", Parents = new List <Parent> { new Parent { Name = "TestParent" } } }; repo.Save(house); House retrieved = repo.Retrieve <House>(house.Id); Parent parent = repo.Retrieve <Parent>(retrieved.Parents[0].Id); Expect.AreEqual(1, parent.Houses.Length); }
public UnitTestRunListener(string resultDirectory, string resultFileName) { DaoRepository = new DaoRepository(new SQLiteDatabase(resultDirectory, resultFileName)); DaoRepository.AddType(typeof(TestResult)); DaoRepository.EnsureDaoAssemblyAndSchema(); }