[Test] 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 setup()
        {
            if (Tests_Consts.offline)
            {
                Assert.Ignore("Ignoring Test because we are offline");
            }

            admin.assert(() => {
                tmFileStorage = new TM_FileStorage(false);

                TM_FileStorage.Custom_WebRoot = "Custom_WebRoot".tempDir();

                tmFileStorage.set_WebRoot()
                .set_Path_XmlDatabase()
                .tmConfig_Load()
                .set_Path_XmlLibraries();

                tmXmlDatabase = tmFileStorage.TMXmlDatabase;
            });
        }
Beispiel #3
0
        [SetUp][Admin] public void setUp()
        {
            UserGroup.Admin.assert();

            //create TM_FileStorage on temp Custom_WebRoot for this TestFixture
            TM_FileStorage.Custom_WebRoot = "custom_WebRoot".tempDir();

            tmFileStorage = new TM_FileStorage(false);
            tmFileStorage.set_WebRoot()
            .set_Path_XmlDatabase()
            .tmServer_Load()
            .set_Path_UserData()
            .load_UserData();
            tmFileStorage.hook_Events_TM_UserData();

            tmXmlDatabase = tmFileStorage.TMXmlDatabase.assert_Not_Null();
            userData      = tmFileStorage.UserData.assert_Not_Null();
            tmServer      = tmFileStorage.Server.assert_Not_Null();

            tmFileStorage.Path_XmlDatabase.assert_Folder_Exists();
            tmFileStorage.Path_UserData.assert_Folder_Exists();

            userDataGit = tmFileStorage.setup_UserData_Git_Support();           // adds Git Support for UserData repos

            tmFileStorage.Path_UserData.isGitRepository().assert_True();

            Assert.NotNull(tmFileStorage.Server.userData_Config());

            userData.createDefaultAdminUser();

            userDataGit.triggerGitCommit();

            nGit = userDataGit.NGit;

            nGit.commits().assert_Size_Is(2, "there should be two commits here");

            UserGroup.None.assert();
        }
Beispiel #4
0
        [Test] 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();
        }