private static void GetRandomStringValues(int numValues, out string[] validStrings, out LargeEnum[] validEnums)
        {
            const int max = (int)LargeEnum.OneHundred + 1;
            validStrings = new string[numValues];
            validEnums = new LargeEnum[numValues];

            for (int i = 0; i < numValues; ++i)
            {
                LargeEnum nextEnum = (LargeEnum)rand.Next(max);
                validEnums[i] = nextEnum;
                validStrings[i] = nextEnum.ToString();
            }
        }
Esempio n. 2
0
        private static void GetRandomStringValues(int numValues, out string[] validStrings, out LargeEnum[] validEnums)
        {
            const int max = (int)LargeEnum.OneHundred + 1;

            validStrings = new string[numValues];
            validEnums   = new LargeEnum[numValues];

            for (int i = 0; i < numValues; ++i)
            {
                LargeEnum nextEnum = (LargeEnum)rand.Next(max);
                validEnums[i]   = nextEnum;
                validStrings[i] = nextEnum.ToString();
            }
        }
Esempio n. 3
0
        public void EnumManager_PreInitalized_TryParse_Performance()
        {
            EnumManager <LargeEnum> .Initalize();

            LargeEnum value;
            LargeEnum otherValue = LargeEnum.One;
            int       length     = validStrings.Length;

            for (int i = 0; i < ITERATIONS; ++i)
            {
                EnumManager <LargeEnum> .TryParse(validStrings[i % length], out value);

                otherValue = value;
            }

            Console.WriteLine(otherValue);
        }
        public void PerformanceParser_Should_Parse_Each_Item_In_Enum_to_String_Map()
        {
            Dictionary <LargeEnum, string> nameToLargeEnumMap;

            Array values = System.Enum.GetValues(typeof(LargeEnum));

            Assert.IsTrue(
                EnumPerformanceParser.TryCreateEnumToNameMap <LargeEnum>(out nameToLargeEnumMap),
                "Unable to parse");

            Assert.AreEqual(values.Length, nameToLargeEnumMap.Count, "Output doesn't match input size");

            for (int i = 0; i < values.Length; ++i)
            {
                LargeEnum value = (LargeEnum)values.GetValue(i);
                Assert.IsTrue(
                    nameToLargeEnumMap.ContainsKey(value),
                    "Value is missing: " + value.ToString());
            }
        }