public void ThrowsDigitIsInvalidExceptionTest() { Exception ex = Record.Exception(() => Roman.RomanToInt("PV")); Assert.NotNull(ex); Assert.IsType <RomanException>(ex); Assert.Equal(RomanExCode.DigitIsInvalid, (ex as RomanException).Code); }
public void ThrowsPreviousDigitIsRepeatedExceptionTest() { Exception ex = Record.Exception(() => Roman.RomanToInt("IIV")); Assert.NotNull(ex); Assert.IsType <RomanException>(ex); Assert.Equal(RomanExCode.PreviousDigitIsRepeated, (ex as RomanException).Code); }
public void ThrowsPreviousDigitIsInvalidExceptionTest() { var numbers = new List <string> { "IC", "IM" }; foreach (var s in numbers) { Exception ex = Record.Exception(() => Roman.RomanToInt(s)); Assert.NotNull(ex); Assert.IsType <RomanException>(ex); Assert.Equal(RomanExCode.PreviousDigitIsInvalid, (ex as RomanException).Code); } }
public void ThrowsDigitIsRepeatedExceptionTest() { var numbers = new List <string> { "IIII", "CMXXXXVIII", "LXVVI" }; foreach (var s in numbers) { Exception ex = Record.Exception(() => Roman.RomanToInt(s)); Assert.NotNull(ex); Assert.IsType <RomanException>(ex); Assert.Equal(RomanExCode.DigitIsRepeated, (ex as RomanException).Code); } }
public void Test1() { var romanNumerals = new Dictionary <string, int> { { "VIII", 8 }, { "XXVI", 26 }, { "LXXIII", 73 } }; foreach (var x in romanNumerals) { int actual = Roman.RomanToInt(x.Key); Assert.Equal(x.Value, actual); } }
public void Test2() { var romanNumerals = new Dictionary <string, int> { { "IV", 4 }, { "IX", 9 }, { "XXIV", 24 }, { "XLIV", 44 }, { "CMXCIX", 999 }, }; foreach (var x in romanNumerals) { int actual = Roman.RomanToInt(x.Key); Assert.Equal(x.Value, actual); } }