private static void RunEnumStringParserDemo() { Dictionary <string, Seasons> map = new Dictionary <string, Seasons> { { "sppringg", Seasons.Spring }, { "Sptring", Seasons.Spring }, { "Summer", Seasons.Summer }, { "SSS", Seasons.Summer }, { "suMMer", Seasons.Summer } }; EnumStringParser <Seasons> parser = new EnumStringParser <Seasons>(map); Seasons result1 = parser.Parse("Sptring"); // Converts to Seasons.Spring Seasons result2 = parser.Parse("SSS"); // Converts to Seasons.Summer }
public void TestParseEnum1() { Dictionary <string, Seasons> map = new Dictionary <string, Seasons> { { "sppringg", Seasons.Spring }, { "Sptring", Seasons.Spring }, { "Summer", Seasons.Summer }, { "SSS", Seasons.Summer }, { "suMMer", Seasons.Summer } }; EnumStringParser <Seasons> parser = new EnumStringParser <Seasons>(map); Seasons expected = Seasons.Spring; Seasons actual = parser.Parse("Sptring"); Assert.AreEqual(expected, actual); }