예제 #1
0
        static bool TestMaxMem()
        {
            Dictionary <string, long> tests = new Dictionary <string, long>();

            tests["12"]      = 12;
            tests["1024"]    = 1024;
            tests["1,024"]   = 1024;
            tests["1Kb"]     = 1024;
            tests["1aa"]     = -1;
            tests["1Mb"]     = 1024 * 1024;
            tests["1Gb"]     = 1024 * 1024 * 1024;
            tests["Gb"]      = -1;
            tests["1,024Kb"] = 1024 * 1024;

            foreach (var kvp in tests)
            {
                try
                {
                    long answer = CacheConfig.ParseMaxNumBytes(kvp.Key);
                    if (answer != kvp.Value)
                    {
                        Console.WriteLine("{0}:{1} != {2}",
                                          kvp.Key, kvp.Value, answer);
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    if (kvp.Value != -1)
                    {
                        Console.WriteLine(ex.Message);
                        return(false);
                    }
                }
            }

            return(true);
        }