Ejemplo n.º 1
0
        /// <summary>
        /// ? physical .env in root folder
        /// </summary>
        /// <returns></returns>
        static async Task <bool> TestEnvironment()
        {
            bool res = Helper.Environment.LoadEnvFile() ? true : false;

            if (res)
            {
                TestTool.PrintSuccess("[Success] Loaded .env file");
            }
            else
            {
                TestTool.PrintFailure("[Error] Failed to load .env file");
            }
            return(res);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ? All global envs are set
        /// </summary>
        /// <returns></returns>
        static async Task <bool> TestEnvVariables()
        {
            bool res = false;

            // Check if global values are set
            try
            {
                Dictionary <string, bool> envs = new Dictionary <string, bool>();
                List <string>             keys = new List <string>()
                {
                    { "host" }, { "db" }, { "usr" }, { "pwd" }, { "port" }
                };

                // Run string values as keys and fetch if are any envs set to that key
                keys.ForEach(key => envs.Add(key, Helper.Globals.Exists(key)));

                // Filter values !== true, keeping the false ones
                envs = envs.Where(a => !a.Value).ToDictionary(i => i.Key, i => i.Value);

                if (envs.Count() > 0)
                {
                    res = false;
                }

                foreach (var env in envs)
                {
                    TestTool.PrintFailure("Missing key for {0}\n", env.Key);
                }
            }
            catch (Exception e)
            {
                TestTool.PrintFailure(e.Message);
                res = false;
            }
            if (res)
            {
                TestTool.PrintSuccess("[Success] for TestEnvVariables()\n");
            }
            return(res);
        }