예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }