public void set_Path_XmlDatabase__UsingFileStorage_On_Custom_WebRoot_without_Read_Privs() { admin.assert(); var tmFileStorage = new TM_FileStorage(false); var tmXmlDatabase = tmFileStorage.TMXmlDatabase; var baseReadOnlyDir = "_tmp_webRoot".tempDir(); var webRootVirualPath = @"virtual/path"; tmFileStorage.WebRoot = baseReadOnlyDir.pathCombine(webRootVirualPath).createDir(); //Check that ensure we can write to baseReadOnlyDir Assert.IsTrue (baseReadOnlyDir.dirExists()); Assert.IsTrue (tmFileStorage.WebRoot.dirExists()); Assert.IsTrue (tmFileStorage.WebRoot.contains(baseReadOnlyDir)); Assert.IsTrue (baseReadOnlyDir.canWriteToPath()); Assert.AreEqual(tmFileStorage.WebRoot.parentFolder().parentFolder(), baseReadOnlyDir); //Now remote the write privileges for all users (on baseReadOnlyDir) while keeping TM_Server.WebRoot writeable baseReadOnlyDir .directoryInfo().deny_Write_Users(); tmFileStorage.WebRoot.directoryInfo().allow_Write_Users(); Assert.IsFalse(baseReadOnlyDir .canWriteToPath()); Assert.IsTrue(tmFileStorage.WebRoot.canWriteToPath()); //Since baseReadOnlyDir can be written, creating an TM_Xml_Database should now default to the App_Data folder (which is on webRootVirualPath ) // var tmXmlDatabase = new TM_Xml_Database().useFileStorage(); tmFileStorage.set_Path_XmlDatabase(); Assert.IsNotNull(tmFileStorage.path_XmlDatabase()); none.assert(); Assert.Ignore("TO FIX (Refactor Side Effect"); Assert.IsTrue (tmFileStorage.path_XmlDatabase().contains("App_Data")); Assert.IsTrue (tmFileStorage.path_XmlDatabase().contains(tmFileStorage.WebRoot)); Assert.IsTrue (tmFileStorage.path_XmlDatabase().contains(PublicDI.config.O2TempDir)); //Finally re enable write so that we can delete the folder baseReadOnlyDir.directoryInfo().allow_Write_Users(); Assert.IsTrue(baseReadOnlyDir.canWriteToPath()); Files.deleteFolder(baseReadOnlyDir, true); Assert.IsFalse (baseReadOnlyDir.dirExists()); }
[Admin] public static TM_FileStorage set_Path_SiteData(this TM_FileStorage tmFileStorage) { UserRole.Admin.demand(); var siteData_Config = tmFileStorage.tmServer().siteData_Config(); if (siteData_Config.isNull() || siteData_Config.Name.notValid()) { "[TM_FileStorage][set_Path_SiteData] set_Path_SiteData or its name was null or empty, so going to to use the default value of: {0}".debug(TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA); siteData_Config = new TM_Server.Config() { Name = TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA }; } var xmlDatabasePath = tmFileStorage.path_XmlDatabase(); // all files are relative to this path var siteDataPath = xmlDatabasePath.pathCombine(siteData_Config.Name); // use the userData_Config.Name as the name of the folder to put UserData files siteDataPath.createDir(); // create if needed if (siteDataPath.dirExists()) { tmFileStorage.Path_SiteData = siteDataPath.createDir(); "[TM_FileStorage] [set_Path_SiteData] TMConfig.Current.UserDataPath: {0}".debug(siteDataPath); } else { tmFileStorage.Path_SiteData = null; "[TM_FileStorage] [set_Path_SiteData] failed to create the folder: {0}".error(siteDataPath); } return(tmFileStorage); }
public static bool library_Deleted(this TM_FileStorage tmFileStorage, TM_Library tmLibrary) { "[xmlDB_DeleteGuidanceExplorer] deleting library with caption: {0}".info(tmLibrary.Caption); var pathToLibraryFolder = tmFileStorage.xmlDB_Path_Library_RootFolder(tmLibrary); // this is also the Library Root if (pathToLibraryFolder.notValid() || pathToLibraryFolder == tmFileStorage.path_XmlDatabase() || pathToLibraryFolder == tmFileStorage.Path_XmlLibraries) { "[xmlDB_DeleteGuidanceExplorer] [Stopping delete] Something is wrong with the pathToLibrary to delete : {0}" .error(pathToLibraryFolder); return(false); } if (pathToLibraryFolder.contains(tmFileStorage.Path_XmlLibraries).isFalse()) { "[xmlDB_DeleteGuidanceExplorer] [Stopping delete] the pathToLibrary should contain tmDatabase.Path_XmlLibraries : {0}" .error(pathToLibraryFolder); return(false); } // the checks above are important since the line below is a recursive folder delete (which can delete a LOT of content is pointed to the wrong folder) if (Files.deleteFolder(pathToLibraryFolder, true).isFalse()) { "[xmlDB_DeleteGuidanceExplorer] there was an error deleting the folder: {0}".error( pathToLibraryFolder); return(false); } "[xmlDB_DeleteGuidanceExplorer] Library folder deleted OK: {0}".info(pathToLibraryFolder); tmFileStorage.reloadGuidanceExplorerObjects(); //reset these return(true); }
public void set_Path_SiteData() { var tmFileStorage = new TM_FileStorage(); var expectedPath = tmFileStorage.path_XmlDatabase().pathCombine(TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA); tmFileStorage.set_Path_SiteData(); Assert.AreEqual(tmFileStorage.Path_SiteData, expectedPath); Assert.True (tmFileStorage.Path_SiteData.dirExists()); // try with a different Name value var tempName = 10.randomLetters(); tmFileStorage.Server.siteData_Config().Name = tempName; tmFileStorage.set_Path_SiteData(); Assert.IsTrue(tmFileStorage.Path_SiteData.contains(tempName)); //check bad data handling tmFileStorage.Server.siteData_Config().Name = null; tmFileStorage.set_Path_SiteData(); Assert.IsTrue(tmFileStorage.Path_SiteData.contains(TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA)); tmFileStorage.Server.siteData_Config().Name = "aaa:bbb"; // will fail to create the SiteData folder and force memory mode tmFileStorage.set_Path_SiteData(); Assert.IsNull (tmFileStorage.Path_SiteData); }
[Admin] public static TM_FileStorage set_Path_UserData(this TM_FileStorage tmFileStorage) { admin.demand(); var tmXmlDatabase = tmFileStorage.tmXmlDatabase(); //var userData = tmFileStorage.userData(); if (tmXmlDatabase.isNull()) { return(tmFileStorage); } var userData_Config = tmFileStorage.tmServer().userData_Config(); if (userData_Config.isNull() || userData_Config.Name.notValid()) { "[TM_Xml_Database][set_Path_UserData] userData_Config or its name was null or empty, so going to to use the default value of: {0}".debug(TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA); userData_Config = new TM_Server.Config() { Name = TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA }; } var xmlDatabasePath = tmFileStorage.path_XmlDatabase(); // all files are relative to this path var userDataPath = xmlDatabasePath.pathCombine(userData_Config.Name); // use the userData_Config.Name as the name of the folder to put UserData files tmFileStorage.Path_UserData = userDataPath; // needed by Git Clone "TeamMentor.Git".assembly() .type("TM_UserData_Git_ExtensionMethods") .invokeStatic("setup_UserData_Git_Support", tmFileStorage); userDataPath.createDir(); // create if needed if (userDataPath.dirExists()) { tmFileStorage.Path_UserData = userDataPath.createDir(); "[TM_Xml_Database] [set_Path_UserData] TMConfig.Current.UserDataPath: {0}".debug(userDataPath); } else { tmFileStorage.Path_UserData = null; "[TM_Xml_Database] [set_Path_UserData] failed to create the folder: {0}".error(userDataPath); } return(tmFileStorage); }
public void set_WebRoot() { TM_FileStorage.Custom_WebRoot = null; var custom_WebRoot = "Custom_WebRoot".tempDir().assert_Folder_Exists(); var expected_Path_XmlDatabase = custom_WebRoot.pathCombine(@"App_Data\TeamMentor"); UserRole.Admin.assert(); TM_FileStorage.Custom_WebRoot.assert_Null(); var tmFileStorage = new TM_FileStorage(loadData: false); tmFileStorage.webRoot().assert_Null(); tmFileStorage.set_WebRoot(); tmFileStorage.webRoot().assert_Not_Null() .assert_Equal(AppDomain.CurrentDomain.BaseDirectory); TM_FileStorage.Custom_WebRoot = custom_WebRoot; tmFileStorage.webRoot().assert_Equal(AppDomain.CurrentDomain.BaseDirectory) // should still point to the AppDomain base directory .assert_Not_Equal(custom_WebRoot); tmFileStorage.using_Custom_WebRoot().assert_False(); // this should only be true when the values match tmFileStorage.set_WebRoot() // set WebRoot .webRoot().assert_Equals(custom_WebRoot); // and confirm its location tmFileStorage.using_Custom_WebRoot().assert_True(); // now it should be true tmFileStorage.path_XmlDatabase().assert_Null(); // confirm that not set tmFileStorage.set_Path_XmlDatabase(); // this should set the TM_Xml_Database inside the Web_Root tmFileStorage.path_XmlDatabase().contains(custom_WebRoot); tmFileStorage.path_XmlDatabase().assert_Is_Equal_To(expected_Path_XmlDatabase); // check that the current Path_XmlDatabase matches the expected location //reset values TM_FileStorage.Custom_WebRoot = null; tmFileStorage.set_WebRoot() .webRoot().assert_Not_Equals(custom_WebRoot); Files.delete_Folder_Recursively(custom_WebRoot).assert_True(); custom_WebRoot.assert_Folder_Doesnt_Exist(); }
public void set_Path_XmlDatabase() { admin.assert(); var custom_WebRoot = TM_FileStorage.Custom_WebRoot = "Custom_WebRoot".tempDir().assert_Folder_Exists(); var tmFileStorage = new TM_FileStorage(loadData: false) .set_WebRoot() .set_Path_XmlDatabase(); var path_XmlDatabase = tmFileStorage.path_XmlDatabase().assert_Folder_Exists() .assert_Contains(custom_WebRoot); // check use of TM_FileStorage.Custom_Path_TM_Xml_Database TM_FileStorage.Custom_Path_XmlDatabase.assert_Null(); TM_FileStorage.Custom_Path_XmlDatabase = 10.randomLetters(); // with a random value tmFileStorage.set_Path_XmlDatabase() .path_XmlDatabase().assert_Is_Equal_To(path_XmlDatabase); // this value should not be changed var custom_Path_TM_Xml_Database = "Custom_Path_TM_Xml_Database".add_5_RandomLetters() .inTempDir() .assert_Folder_Doesnt_Exist(); TM_FileStorage.Custom_Path_XmlDatabase = custom_Path_TM_Xml_Database; // with a folder that doesn't exist tmFileStorage.set_Path_XmlDatabase() .path_XmlDatabase().assert_Is_Equal_To(path_XmlDatabase); // should still be unchanged custom_Path_TM_Xml_Database.createDir().assert_Folder_Exists(); // create the folder tmFileStorage.set_Path_XmlDatabase() .path_XmlDatabase().assert_Is_Equal_To(custom_Path_TM_Xml_Database); // and the value should be set Files.delete_Folder_Recursively(custom_Path_TM_Xml_Database).assert_True(); Files.delete_Folder_Recursively(custom_WebRoot ).assert_True(); none.assert(); }
public void set_Default_Values() { var tmFileStorage = new TM_FileStorage(false); var tmXmlDatabase = tmFileStorage.TMXmlDatabase; var events = tmXmlDatabase.Events; // this value should not change tmXmlDatabase.set_Default_Values(); Assert.NotNull (tmXmlDatabase); Assert.IsEmpty (tmXmlDatabase.Cached_GuidanceItems); Assert.IsEmpty (tmFileStorage.GuidanceItems_FileMappings); Assert.IsEmpty (tmXmlDatabase.GuidanceExplorers_XmlFormat); Assert.IsEmpty (tmXmlDatabase.VirtualArticles); Assert.AreEqual (tmXmlDatabase.Events, events); Assert.IsNull (tmFileStorage.path_XmlDatabase()); Assert.IsEmpty (tmFileStorage.GuidanceExplorers_Paths); Assert.IsNull (tmFileStorage.Path_XmlLibraries); Assert.IsNotNull(tmFileStorage.UserData); Assert.IsNotNull(tmFileStorage.Server); }
[Admin] public static TM_FileStorage set_Path_XmlLibraries(this TM_FileStorage tmFileStorage) { UserRole.Admin.demand(); var tmXmlDatabase = tmFileStorage.tmXmlDatabase(); var tmConfig = TMConfig.Current; if (tmXmlDatabase.isNull() || tmConfig.isNull()) { return(tmFileStorage); } try { var xmlDatabasePath = tmFileStorage.path_XmlDatabase(); // tmConfig.xmlDatabasePath(); var libraryPath = tmConfig.TMSetup.XmlLibrariesPath; "[TM_Xml_Database] [SetPaths_XmlDatabase] TM_Xml_Database.path_XmlDatabase(): {0}".debug(xmlDatabasePath); "[TM_Xml_Database] [SetPaths_XmlDatabase] TMConfig.Current.XmlLibrariesPath: {0}".debug(libraryPath); if (libraryPath.dirExists().isFalse()) { libraryPath = xmlDatabasePath.pathCombine(libraryPath); libraryPath.createDir(); // make sure it exists } tmFileStorage.Path_XmlLibraries = libraryPath; "[TM_Xml_Database] [SetPaths_XmlDatabase] tmXmlDatabase.Path_XmlLibraries = {0}".info(libraryPath); "[TM_Xml_Database] Paths configured".info(); } catch (Exception ex) { "[TM_Xml_Database] [set_Path_XmlLibraries]: {0} \n\n {1}".error(ex.Message, ex.StackTrace); } tmXmlDatabase.Events.After_Set_Path_XmlLibraries.raise(); return(tmFileStorage); }
public void set_Path_XmlDatabase__UsingFileStorage_On_Custom_WebRoot() { var tmFileStorage = new TM_FileStorage(false); //Assert.AreEqual(tmFileStorage.WebRoot, AppDomain.CurrentDomain.BaseDirectory); tmFileStorage.WebRoot = "_tmp_webRoot".tempDir().info(); tmFileStorage.WebRoot.delete_Folder(); Assert.IsFalse(tmFileStorage.WebRoot.dirExists()); tmFileStorage.set_Path_XmlDatabase(); Assert.IsTrue (tmFileStorage.path_XmlDatabase().dirExists(), "db ctor should create a library folder"); var usingAppDataFolder = TM_Status.Current.TM_Database_Location_Using_AppData; "*** DB path: {0}".info(tmFileStorage.path_XmlDatabase()); "*** Lib path: {0}".info(tmFileStorage.Path_XmlLibraries); "*** Current WebRoot: {0}".debug(tmFileStorage.WebRoot); "*** Current WebRoot exists: {0}".debug(tmFileStorage.WebRoot.dirExists()); "*** TM_Status.Current.TM_Database_Location_Using_AppData: {0}".debug(TM_Status.Current.TM_Database_Location_Using_AppData); Assert.AreEqual(usingAppDataFolder, tmFileStorage.WebRoot.dirExists() , "db ctor should not create a Web Root (if it doesn't exist)"); Assert.AreEqual(usingAppDataFolder, tmFileStorage.path_XmlDatabase().contains ("App_Data")); Assert.AreEqual(usingAppDataFolder, tmFileStorage.path_XmlDatabase().contains (tmFileStorage.WebRoot)); Assert.AreEqual(usingAppDataFolder, tmFileStorage.path_XmlDatabase().contains (PublicDI.config.O2TempDir)); tmFileStorage.delete_Database(); Assert.AreEqual(usingAppDataFolder, tmFileStorage.WebRoot.dirExists() , "if not usingAppDataFolder the TM_Server.WebRoot shouldn't exist"); Assert.IsFalse(tmFileStorage.path_XmlDatabase().dirExists() , "should had been deleted"); }
public void set_Path_UserData() { var tmFileStorage = new TM_FileStorage(); var expectedPath = tmFileStorage.path_XmlDatabase().pathCombine(TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA); tmFileStorage.set_Path_UserData(); var userData = tmFileStorage.UserData; //Assert.NotNull (tmServer); Assert.NotNull (userData); Assert.AreEqual(tmFileStorage.Path_UserData, expectedPath); Assert.True (tmFileStorage.Path_UserData.dirExists()); // try with a different Name value var tempName = 10.randomLetters(); tmFileStorage.Server.userData_Config().Name = tempName; tmFileStorage.set_Path_UserData(); Assert.IsTrue(tmFileStorage.Path_UserData.contains(tempName)); tmFileStorage.delete_Database(); Assert.False (tmFileStorage.Path_UserData.dirExists()); //check bad data handling tmFileStorage.Server.userData_Config().Name = null; tmFileStorage.set_Path_UserData(); Assert.IsTrue(tmFileStorage.Path_UserData.contains(TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA)); tmFileStorage.Server.userData_Config().Name = "aaa:bbb"; // will fail to create the UserData folder and force memory mode tmFileStorage.set_Path_UserData(); Assert.IsNotNull (tmFileStorage.UserData); Assert.IsNull (tmFileStorage.Path_UserData); //test nulls tmFileStorage.Server = null; tmFileStorage.UserData = null; tmFileStorage.TMXmlDatabase = null; tmFileStorage.set_Path_UserData(); Assert.IsNull (tmFileStorage.Path_UserData); //Assert.IsNull (new TM_FileStorage(false).set_Path_UserData().Path_UserData); }
public void tm_Server_Save() { var tmFileStorage = new TM_FileStorage(); Assert.NotNull(tmFileStorage.path_XmlDatabase()); var tmServerLocation = tmFileStorage.tmServer_Location(); var tmServer_withDefaultData = new TM_Server().setDefaultData(); Assert.IsTrue(tmServerLocation.fileExists()); // Assert.Ignore("TO FIX (Refactor Side Effect"); Assert.AreEqual(tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); var tmpName1 = 10.randomLetters(); tmFileStorage.Server.UserData_Configs.first().Name = tmpName1; Assert.IsTrue(tmFileStorage.tmServer_Save()); Assert.AreEqual(tmServerLocation.load<TM_Server>().UserData_Configs.first().Name, tmpName1); //check that it was saved /* // this works but makes the test run in 10s (and the test being done is if there is no exception) var tmpName2 = 10.randomLetters(); tmServerLocation.fileInfo() .setAccessControl("Users", FileSystemRights.Write, AccessControlType.Deny); tmXmlDatabase.Server.UserData_Configs.first().Name = tmpName2; Assert.IsFalse(tmXmlDatabase.tmServer_Save()); Assert.AreEqual(tmServerLocation.load<TM_Server>().UserData_Configs.first().Name, tmpName1); //check that it was not saved Assert.IsTrue(tmServerLocation.delete_File()); Assert.IsFalse(tmServerLocation.fileExists()); */ tmFileStorage.delete_Database(); Assert.IsFalse(tmServerLocation.fileExists()); Assert.IsFalse(tmFileStorage.path_XmlDatabase().dirExists()); //check when not UsingFileStorage //check for nulls tmFileStorage.Path_XmlDatabase = null; Assert.IsFalse(tmFileStorage.tmServer_Save()); Assert.IsFalse(new TM_FileStorage(false).tmServer_Save()); }
public void tm_Server_Load_UsingFileStorage() { var tmFileStorage = new TM_FileStorage(false); var baseReadOnlyDir = "_tmp_webRoot".tempDir(); var webRootVirualPath = @"site\wwwroot"; // simulates use of AppData tmFileStorage.WebRoot = baseReadOnlyDir.pathCombine(webRootVirualPath).createDir(); tmFileStorage.set_Path_XmlDatabase() .set_Path_UserData() .tmServer_Load(); var tmServerFile = tmFileStorage.tmServer_Location(); var expectedLocation = tmFileStorage.Path_XmlDatabase.pathCombine(TMConsts.TM_SERVER_FILENAME); Assert.IsNotNull(tmFileStorage.path_XmlDatabase()); Assert.IsTrue (TM_Status.Current.TM_Database_Location_Using_AppData); Assert.NotNull (tmFileStorage.Server); Assert.IsTrue (tmServerFile.fileExists()); Assert.AreEqual(tmServerFile, expectedLocation); // Assert.Ignore("TO FIX (Refactor Side Effect"); // Assert.Ignore("TO FIX (Refactor Side Effect"); var tmServer_withDefaultData = new TM_Server().setDefaultData(); Assert.AreEqual(tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); //make a change, saved it and ensure it gets loaded ok var tmpName1 = 10.randomLetters(); var tmpName2 = 10.randomLetters(); tmFileStorage.Server.UserData_Configs.first().Name = tmpName1; tmFileStorage.tmServer_Save(); tmFileStorage.Server.UserData_Configs.first().Name = tmpName2; tmFileStorage.tmServer_Load(); Assert.AreEqual (tmFileStorage.Server.UserData_Configs.first().Name, tmpName1); Assert.AreNotEqual(tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); //Try loading up an corrupted tmServer (whcih will default to load a default TM_Server "aaaa".saveAs(tmServerFile); tmFileStorage.tmServer_Load(); Assert.AreNotEqual(tmFileStorage.Server.UserData_Configs.first().Name, tmpName1); Assert.AreEqual (tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); Files.deleteFolder(baseReadOnlyDir, true); Assert.IsFalse(baseReadOnlyDir.dirExists()); //tmXmlDatabase.delete_Database(); }
[Admin] public static string tmServer_Location(this TM_FileStorage tmFileStorage) { UserRole.Admin.demand(); return(tmFileStorage.path_XmlDatabase() .pathCombine(TMConsts.TM_SERVER_FILENAME)); }
public void set_Path_XmlDatabase__UsingFileStorage_On_AppData__without_Read_Privs() { var tmFileStorage = new TM_FileStorage(false); var tmXmlDatabase = tmFileStorage.TMXmlDatabase; var baseReadOnlyDir = "_tmp_webRoot".tempDir(); var webRootVirualPath = @"site\wwwroot"; // simulates use of AppData tmFileStorage.WebRoot = baseReadOnlyDir.pathCombine(webRootVirualPath).createDir(); tmFileStorage.WebRoot.directoryInfo().deny_CreateDirectories_Users(); //var tmXmlDatabase = new TM_Xml_Database().useFileStorage(); // usually a true paramater will set UsingFileStorage to true tmFileStorage.set_Path_XmlDatabase(); Assert.IsNull (tmFileStorage.path_XmlDatabase()); // if we can't write to the AppData folder then this value can't be set automatically Assert.IsFalse(tmXmlDatabase.usingFileStorage()); // and the offline mode (i.e. UsingFileStorage = false) should be activated Files.deleteFolder(baseReadOnlyDir, true); Assert.IsFalse(baseReadOnlyDir.dirExists()); }
public void set_Path_XmlDatabase__UsingFileStorage() { var tmFileStorage = new TM_FileStorage(); var tmXmlDatabase = tmFileStorage.TMXmlDatabase; tmFileStorage.set_Path_XmlDatabase(); Assert.AreEqual (tmXmlDatabase, TM_Xml_Database.Current); Assert.IsTrue (tmXmlDatabase.usingFileStorage()); Assert.IsNotNull (tmFileStorage.path_XmlDatabase()); tmFileStorage.delete_Database(); }
public void set_Path_XmlDatabase__In_Memory() { var tmFileStorage = new TM_FileStorage(false); var tmXmlDatabase = tmFileStorage.TMXmlDatabase; Assert.AreEqual(tmFileStorage, tmFileStorage.set_Path_XmlDatabase()); Assert.AreEqual(tmXmlDatabase, TM_Xml_Database.Current); Assert.IsNull (tmFileStorage.path_XmlDatabase()); Assert.IsFalse (tmXmlDatabase.usingFileStorage()); var tmXmlDatabase2 = new TM_Xml_Database(); Assert.AreNotEqual(tmXmlDatabase, tmXmlDatabase2, "A new tmXmlDatabase1 should had been created"); Assert.AreEqual (tmXmlDatabase2, TM_Xml_Database.Current); }
public void Application_Start() { UserGroup.Admin.assert(); // impersonate an admin to load the database "[TM_StartUp] Application Start".info(); TmFileStorage = new TM_FileStorage(); // this will trigger the load of all TM_Xml_Database data TmFileStorage.UserData.createDefaultAdminUser(); // ensures that there is an valid admin TrackingApplication = new Tracking_Application(TmFileStorage.path_XmlDatabase()); // Enabled Application Tracking TM_REST.SetRouteTable(); // Set REST routes MVC5.MapDefaultRoutes(); // Map MVC 5 routes TrackingApplication.saveLog(); // save log UserGroup.None.assert(); // revert admin user impersonation }
public void set_Path_XmlLibraries() { var tmFileStorage = new TM_FileStorage(false); TMConfig.Current = null; //this is the sequence that needs to be loaded in order to have a Path for Xml Libraries tmFileStorage.set_WebRoot() .set_Path_XmlDatabase() .tmServer_Load() .set_Path_UserData() // .tmConfig_Load() // .set_Path_XmlLibraries(); Assert.NotNull(tmFileStorage.path_XmlDatabase()); Assert.NotNull(tmFileStorage.path_XmlLibraries()); Assert.IsTrue (tmFileStorage.path_XmlDatabase().dirExists()); Assert.IsTrue (tmFileStorage.path_XmlLibraries().dirExists()); Assert.NotNull(TMConfig.Current); //test nulls tmFileStorage.Path_XmlLibraries =null; //in the scenarios below the tmFileStorage.Path_XmlLibraries should not be set if(TMConfig.Current.notNull()) TMConfig.Current.TMSetup = null; tmFileStorage.set_Path_XmlLibraries(); TMConfig.Current = null; tmFileStorage.set_Path_XmlLibraries(); Assert.IsNull(tmFileStorage.Path_XmlLibraries); //tmXmlDatabase.delete_Database(); //TMConfig.Current = new TMConfig(); }