public void RomanNumeral_Parse_ClassicNotation() { Assert.AreEqual(1, RomanNumeral.Parse("I").Number); Assert.AreEqual(2, RomanNumeral.Parse("II").Number); Assert.AreEqual(3, RomanNumeral.Parse("III").Number); Assert.AreEqual(4, RomanNumeral.Parse("IIII").Number); Assert.AreEqual(5, RomanNumeral.Parse("V").Number); Assert.AreEqual(6, RomanNumeral.Parse("VI").Number); Assert.AreEqual(7, RomanNumeral.Parse("VII").Number); Assert.AreEqual(8, RomanNumeral.Parse("VIII").Number); Assert.AreEqual(9, RomanNumeral.Parse("VIIII").Number); Assert.AreEqual(10, RomanNumeral.Parse("X").Number); Assert.AreEqual(11, RomanNumeral.Parse("XI").Number); Assert.AreEqual(1910, RomanNumeral.Parse("MDCCCCX").Number); Assert.AreEqual(1910, RomanNumeral.Parse("MCMX").Number); Assert.AreEqual(118, RomanNumeral.Parse("CXVIII").Number); Assert.AreEqual(118, RomanNumeral.Parse("CIIXX").Number); Assert.AreEqual(118, RomanNumeral.Parse("CXIIX").Number); Assert.AreEqual(119, RomanNumeral.Parse("CXVIIII").Number); Assert.AreEqual(119, RomanNumeral.Parse("CXIX").Number); Assert.AreEqual(0, RomanNumeral.Parse("NULLA").Number); }
public void RomanNumeral_Parse_InvalidClassicNotation() { //substractive notation Assert.IsNull(RomanNumeral.Parse("IV")); Assert.IsNull(RomanNumeral.Parse("IX")); //invalid order Assert.IsNull(RomanNumeral.Parse("IVL")); //valid order Assert.IsNotNull(RomanNumeral.Parse("LVI")); }
public static string operator -(string r1, RomanNumeral r2) { var r = RomanNumeral.Parse(r1) + r2; return(r.ToString()); }
public static RomanNumeral operator +(RomanNumeral r1, string r2) { return(r1 + RomanNumeral.Parse(r2)); }