/*[Admin] public static TM_FileStorage load_TMServer(this TM_FileStorage tmFileStorage) * { * return tmFileStorage.tmServer_Load(); * }*/ [Admin] public static TM_FileStorage tmServer_Load(this TM_FileStorage tmFileStorage) { UserRole.Admin.demand(); if (tmFileStorage.isNull()) { return(tmFileStorage); } var tmServer = new TM_Server(); tmServer.setDefaultData(); var location = tmFileStorage.tmServer_Location(); if (location.valid()) { if (location.fileExists().isFalse()) { "[TM_Xml_Database][load_TMServer_Config] expected TM_Server file didn't exist, so creating it: {0}".info(location); tmServer.saveAs(location); } var loadedTmServer = location.load <TM_Server>(); if (loadedTmServer.isNull()) { "[TM_Xml_Database][load_TMServer_Config] Failed to load tmServer file: {0} Default values will be used".error(location); } else { tmServer = loadedTmServer; } } //tmDatabase.Events.After_TmServer_Load.raise(); tmFileStorage.Server = tmServer; return(tmFileStorage); }
[Test] public void setDefaultData() { var tmServer = new TM_Server(); tmServer.setDefaultData(); Assert.IsNotEmpty(tmServer.UserData_Configs); Assert.IsNotEmpty(tmServer.SiteData_Configs); Assert.AreEqual(1, tmServer.UserData_Configs.size()); Assert.AreEqual(1, tmServer.SiteData_Configs.size()); var userData = tmServer.userData_Config(); Assert.AreEqual(userData.Name, TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA); Assert.AreEqual(userData.Active, true); // Assert.AreEqual(userData.Use_FileSystem , false); // Assert.AreEqual(userData.Enable_Git_Support , false); var siteData = tmServer.siteData_Config(); Assert.AreEqual(siteData.Name, TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA); Assert.AreEqual(siteData.Active, true); // Assert.AreEqual(siteData.Use_FileSystem , false); // Assert.AreEqual(siteData.Enable_Git_Support , false); }