public void WhenToRomanNumeralIsInitializedToUseExpandedRomanNumeralsItReturnsARomanNumeral() { // 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 <long, char> expandedNumeralLookup = new Dictionary <long, char>() { { 10000, 'A' }, { 5000, 'B' }, { 1000, 'M' }, { 500, 'D' }, { 100, 'C' }, { 50, 'L' }, { 10, 'X' }, { 5, 'V' }, { 1, 'I' } }; ToRomanNumeral fourteenThousandTwoHundredSixtyFour = new ToRomanNumeral(14264, expandedNumeralLookup); Assert.AreEqual("AMBCCLXIV", fourteenThousandTwoHundredSixtyFour.GenerateRomanNumeralRepresentation()); int overMaxNumeral = 40000; Assert.ThrowsException <ArgumentOutOfRangeException>(() => overMaxNumeral.ToRomanNumeral()); }
public void WhenToRomanNumeralIsInitializedToUseAlternateRomanNumeralsItReturnsARomanNumeral() { Dictionary <long, char> alternateNumeralLookup = new Dictionary <long, char>() { { 1000, 'G' }, { 500, 'F' }, { 100, 'E' }, { 50, 'D' }, { 10, 'C' }, { 5, 'B' }, { 1, 'A' } }; ToRomanNumeral fourteen = new ToRomanNumeral(14, alternateNumeralLookup); Assert.AreEqual("CAB", fourteen.GenerateRomanNumeralRepresentation()); ToRomanNumeral nineteenEightyNine = new ToRomanNumeral(1989, alternateNumeralLookup); Assert.AreEqual("GEGDCCCAC", nineteenEightyNine.GenerateRomanNumeralRepresentation()); }
public static string ToRomanNumeral(this long baseTenNumber) { ToRomanNumeral romanNumeral = new ToRomanNumeral(baseTenNumber); return(romanNumeral.GenerateRomanNumeralRepresentation()); }