public void WhenFromRomanNumeralIsInitializedToUseExpandedRomanNumeralsItReturnsArabic() { // The real numerals over 1000 are letters with bars over them. Since that isn't easy to // re-create, I'm substituting alternate letters Dictionary <string, long> expandedNumeralValueLookup = new Dictionary <string, long>(StringComparer.CurrentCultureIgnoreCase) { { "I", 1 }, { "V", 5 }, { "X", 10 }, { "L", 50 }, { "C", 100 }, { "D", 500 }, { "M", 1000 }, { "B", 5000 }, { "A", 10000 } }; FromRomanNumeral fourteenThousandTwoHundredSixtyFour = new FromRomanNumeral("AMBCCLXIV", expandedNumeralValueLookup); Assert.AreEqual(14264, fourteenThousandTwoHundredSixtyFour.GenerateArabicRepresentation()); }
public void WhenFromRomanNumeralIsInitializedToUseAlternateRomanNumeralsItReturnsArabic() { // this is well outside of the scope of the kata, but it is a demonstration of the flexibility of the solution Dictionary <string, long> alternateNumeralValueLookup = new Dictionary <string, long>(StringComparer.CurrentCultureIgnoreCase) { { "A", 1 }, { "B", 5 }, { "C", 10 }, { "D", 50 }, { "E", 100 }, { "F", 500 }, { "G", 1000 } }; FromRomanNumeral fourteen = new FromRomanNumeral("CAB", alternateNumeralValueLookup); Assert.AreEqual(14, fourteen.GenerateArabicRepresentation()); FromRomanNumeral nineteenEightyNine = new FromRomanNumeral("GEGDCCCAC", alternateNumeralValueLookup); Assert.AreEqual(1989, nineteenEightyNine.GenerateArabicRepresentation()); }
public static long ParseAsRomanNumeral(this string romanNumeral) { FromRomanNumeral fromRomanNumeral = new FromRomanNumeral(romanNumeral); return(fromRomanNumeral.GenerateArabicRepresentation()); }