Beispiel #1
0
        public void ToArabic_return_8_when_VIII()
        {
            var target = new NumeralConverter();
            var actual = target.ToArabic("VIII");

            Assert.AreEqual(8, actual);
        }
Beispiel #2
0
        public void ToArabic_return_9_when_IX()
        {
            var target = new NumeralConverter();
            var actual = target.ToArabic("IX");

            Assert.AreEqual(9, actual);
        }
Beispiel #3
0
        public void ToArabic_return_3888_when_MMMDCCCLXXXVIII()
        {
            var target = new NumeralConverter();
            var actual = target.ToArabic("MMMDCCCLXXXVIII");

            Assert.AreEqual(3888, actual);
        }
Beispiel #4
0
        public void ToArabic_return_2016_when_MMXVI()
        {
            var target = new NumeralConverter();
            var actual = target.ToArabic("MMXVI");

            Assert.AreEqual(2016, actual);
        }
Beispiel #5
0
        public void ToArabic_return_50_when_L()
        {
            var target = new NumeralConverter();
            var actual = target.ToArabic("L");

            Assert.AreEqual(50, actual);
        }
Beispiel #6
0
        public void ToArabic_returns_0_when_empty_string()
        {
            var target = new NumeralConverter();
            var actual = target.ToArabic("");

            Assert.AreEqual(0, actual);
        }
Beispiel #7
0
        public static string Add(string addend1, string addend2)
        {
            var numericAddend1 = NumeralConverter.ToArabic(addend1);
            var numericAddend2 = NumeralConverter.ToArabic(addend2);

            var sum = numericAddend1 + numericAddend2;

            return(ArabicConverter.ToNumeral(sum));
        }
Beispiel #8
0
        public void ConvertToArabic_CaseIsIgnored()
        {
            const string numeral  = "xxV";
            var          expected = 25;

            var result = NumeralConverter.ToArabic(numeral);

            result.Should().Be(expected);
        }
Beispiel #9
0
        public void ConvertToArabic_WhenPassedSubtractiveNumeral_ReturnsCorrectIntegerValue()
        {
            const string numeral  = "IV";
            var          expected = 4;

            var result = NumeralConverter.ToArabic(numeral);

            result.Should().Be(expected);
        }
Beispiel #10
0
        public void ConvertToArabic_WhenPassedIIReturns2()
        {
            const string numeral  = "II";
            var          expected = 2;

            var result = NumeralConverter.ToArabic(numeral);

            result.Should().Be(expected);
        }
Beispiel #11
0
        public void ConvertToArabic_WhenPassedNumeralWithIllegalCharacterRepetitions_Throws()
        {
            const string numeral1 = "IIII";
            const string numeral2 = "DD";
            const string numeral3 = "VIIII";

            Assert.Throws <ArgumentException>(() => NumeralConverter.ToArabic(numeral1));
            Assert.Throws <ArgumentException>(() => NumeralConverter.ToArabic(numeral2));
            Assert.Throws <ArgumentException>(() => NumeralConverter.ToArabic(numeral3));
        }
Beispiel #12
0
        public void ConvertToArabic_WhenPassedNumeralWithIllegalCharacters_Throws()
        {
            const string badNumeral = "WAT";

            Assert.Throws <ArgumentException>(() => NumeralConverter.ToArabic(badNumeral));
        }
Beispiel #13
0
        public void ToArabic_throws_exception_when_InvalidFormat()
        {
            var target = new NumeralConverter();

            target.ToArabic("IIX");
        }
Beispiel #14
0
        public void ToArabic_throws_exception_when_InvalidCharater()
        {
            var target = new NumeralConverter();

            target.ToArabic("S");
        }