public string Add(RomanNumber rhs) { var thisInt = this.ToInt(); var otherInt = rhs.ToInt(); int result = thisInt + otherInt; string resStr = ""; resStr += this.AddDivisor(10, 'X', ref result); resStr += this.AddDivisor(5, 'V', ref result); resStr += this.AddDivisor(1, 'I', ref result); resStr = resStr.Replace("IIII", "IV"); return resStr; }
public void ConvertsToRomanCorrectly(string lhs, string rhs, string expectedRoman) { var lhsRoman = new RomanNumber(lhs); var rhsRoman = new RomanNumber(rhs); var result = lhsRoman.Add(rhsRoman); Assert.AreEqual(result, expectedRoman); }
public void ConvertsToIntegerCorrectly(string roman, int expectedInt) { var romanNumber = new RomanNumber(roman); Assert.AreEqual(expectedInt, romanNumber.ToInt()); }