public void ThrowsExceptionForSubstractionFaultForX() { var exceptionForD = false; var exceptionForM = false; try { RomanToDecimalConverter.Convert("ID"); } catch (InvalidRomanNumberException) { exceptionForD = true; } try { RomanToDecimalConverter.Convert("IM"); } catch (InvalidRomanNumberException) { exceptionForM = true; } Assert.AreEqual(11, RomanToDecimalConverter.Convert("XI")); Assert.AreEqual(15, RomanToDecimalConverter.Convert("XV")); Assert.AreEqual(20, RomanToDecimalConverter.Convert("XX")); Assert.AreEqual(40, RomanToDecimalConverter.Convert("XL")); Assert.AreEqual(90, RomanToDecimalConverter.Convert("XC")); Assert.IsTrue(exceptionForD); Assert.IsTrue(exceptionForM); }
public void DNeverCanSubtracted() { var exceptionForDD = false; var exceptionForDM = false; Assert.AreEqual(501, RomanToDecimalConverter.Convert("DI")); Assert.AreEqual(505, RomanToDecimalConverter.Convert("DV")); Assert.AreEqual(510, RomanToDecimalConverter.Convert("DX")); Assert.AreEqual(550, RomanToDecimalConverter.Convert("DL")); Assert.AreEqual(600, RomanToDecimalConverter.Convert("DC")); try { RomanToDecimalConverter.Convert("DD"); } catch (InvalidRomanNumberException) { exceptionForDD = true; } try { RomanToDecimalConverter.Convert("DM"); } catch (InvalidRomanNumberException) { exceptionForDM = true; } Assert.IsTrue(exceptionForDD); Assert.IsTrue(exceptionForDM); }
public void ThrowsExceptionForSubstractionFaultForI() { var exceptionForL = false; var exceptionForC = false; var exceptionForD = false; var exceptionForM = false; try{ RomanToDecimalConverter.Convert("IL"); } catch (InvalidRomanNumberException) { exceptionForL = true; } try { RomanToDecimalConverter.Convert("IC"); } catch (InvalidRomanNumberException) { exceptionForC = true; } try { RomanToDecimalConverter.Convert("ID"); } catch (InvalidRomanNumberException) { exceptionForD = true; } try { RomanToDecimalConverter.Convert("IM"); } catch (InvalidRomanNumberException) { exceptionForM = true; } Assert.IsTrue(exceptionForL); Assert.IsTrue(exceptionForC); Assert.IsTrue(exceptionForD); Assert.IsTrue(exceptionForM); Assert.AreEqual(4, RomanToDecimalConverter.Convert("IV")); Assert.AreEqual(9, RomanToDecimalConverter.Convert("IX")); }
public RomanToDecimalConverterTests() { _target = new RomanToDecimalConverter(); }
public void ThrowsExceptionForRepettitionFaultForM() { RomanToDecimalConverter.Convert("MMMM"); }