Ejemplo n.º 1
0
        public void EnumManager_Should_Parse_Strings_Without_Initalization()
        {
            SmallEnum parsedValue;

            Assert.IsTrue(EnumManager <SmallEnum> .TryParse(oneString, out parsedValue), "Parsing failed with existing value");

            Assert.AreEqual(oneValue, parsedValue, oneString + " parsed to unexpected value " + oneValue.ToString());
        }
        public void PerformanceParser_Should_Parse_Each_Item_In_String_to_Enum_Map()
        {
            Dictionary <string, SmallEnum> nameToSmallEnumMap;

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

            Assert.IsTrue(
                EnumPerformanceParser.TryCreateNameToEnumMap <SmallEnum>(out nameToSmallEnumMap),
                "Unable to parse");

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

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