public void GetLayoutInfoTest() { string layoutCountSQL = string.Format(@"select count (*) from tasLayout where idflQuery = {0} and (idfPerson = {1} or blnShareLayout=1)", BaseReportTests.QueryId, (long)EidssUserContext.User.EmployeeID); string folderCountSQL = @"select count (*) from tasLayoutFolder where idflQuery = " + BaseReportTests.QueryId; lock (m_LayoutDB.Connection) { EidssUserContext.CheckUserLoggedIn(); PresenterFactory.SharedPresenter.SharedModel.SelectedQueryId = BaseReportTests.QueryId; int layoutCount = GetCount(layoutCountSQL); int folderCount = GetCount(folderCountSQL); LookupManager.ClearAndReloadOnIdle(); int actualLayoutCount = AvrQueryLayoutTreeDbHelper.LoadLayouts(false, BaseReportTests.QueryId).Count; Assert.AreEqual(layoutCount, actualLayoutCount); int actualFolderCount = AvrQueryLayoutTreeDbHelper.LoadFolders(false, BaseReportTests.QueryId).Count; Assert.AreEqual(folderCount, actualFolderCount); } }
public void UpdateFoldersTest() { lock (m_SyncLock) { PresenterFactory.SharedPresenter.SharedModel.SelectedQueryId = m_TestQueryId; long layoutId = CreateLayout(); try { List <AvrTreeElement> original = AvrQueryLayoutTreeDbHelper.LoadQueries(); original.AddRange(AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId)); EidssUserContext.CheckUserLoggedIn(); original.AddRange(AvrQueryLayoutTreeDbHelper.LoadLayouts(false, m_TestQueryId)); var final = new List <AvrTreeElement>(original); AvrTreeElement layout = original.Find(ById(layoutId)); Assert.IsNotNull(layout); AvrTreeElement folder1 = CreateFolderItem(null, "Folder1", "Nat f1"); AvrQueryLayoutTreeDbHelper.SaveFolder(folder1.ID, folder1.ParentID, m_TestQueryId, folder1.DefaultName, folder1.NationalName); AvrTreeElement folder2 = CreateFolderItem(folder1.ID, "Folder2", "Nat f2"); AvrQueryLayoutTreeDbHelper.SaveFolder(folder2.ID, folder2.ParentID, m_TestQueryId, folder2.DefaultName, folder2.NationalName); AvrTreeElement folder3 = CreateFolderItem(folder2.ID, "Folder3", "Nat f3"); AvrQueryLayoutTreeDbHelper.SaveFolder(folder3.ID, folder3.ParentID, m_TestQueryId, folder3.DefaultName, folder3.NationalName); final.AddRange(new[] { folder1, folder2, folder3 }); layout.ParentID = folder1.ID; LookupManager.ClearAndReloadOnIdle(); List <AvrTreeElement> saved = AvrQueryLayoutTreeDbHelper.LoadQueries(); saved.AddRange(AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId)); EidssUserContext.CheckUserLoggedIn(); saved.AddRange(AvrQueryLayoutTreeDbHelper.LoadLayouts(false, m_TestQueryId)); AvrTreeElement newFolder1 = saved.Find(ById(folder1.ID)); Assert.IsNotNull(newFolder1); AvrTreeElement newFolder2 = saved.Find(ById(folder2.ID)); Assert.IsNotNull(newFolder2); AvrTreeElement newFolder3 = saved.Find(ById(folder3.ID)); Assert.IsNotNull(newFolder3); AvrTreeElement newLayout = saved.Find(ById(layoutId)); Assert.IsNotNull(newLayout); Assert.AreEqual(m_TestQueryId, newFolder1.ParentID); Assert.AreEqual(newFolder1.ID, newFolder2.ParentID); Assert.AreEqual(newFolder2.ID, newFolder3.ParentID); Assert.AreEqual(m_TestQueryId, newLayout.ParentID); newLayout.ParentID = m_TestQueryId; layout.ParentID = m_TestQueryId; LookupManager.ClearAndReloadOnIdle(); int oldFoldersCount = AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId).Count; // delete saved folders using (var avrDbService = new Folder_DB()) { Assert.IsTrue(avrDbService.Delete(folder3.ID), string.Format("could not delete folder '{0}' because of '{1}'", folder3.ID, avrDbService.LastError)); Assert.IsTrue(avrDbService.Delete(folder2.ID), string.Format("could not delete folder '{0}' because of '{1}'", folder2.ID, avrDbService.LastError)); Assert.IsTrue(avrDbService.Delete(folder1.ID), string.Format("could not delete folder '{0}' because of '{1}'", folder1.ID, avrDbService.LastError)); } LookupManager.ClearAndReloadOnIdle(); Assert.AreEqual(oldFoldersCount - 3, AvrQueryLayoutTreeDbHelper.ReLoadFolders(false, m_TestQueryId).Count); } finally { DeleteLayout(layoutId); } } }