Esempio n. 1
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));
        }
        public void ConvertArabicToNumeral_WhenPassedANonBaseValue_ReturnsTheCorrectNumeral()
        {
            const int    number   = 19;
            const string expected = "XIX";

            var result = ArabicConverter.ToNumeral(number);

            result.Should().Be(expected);
        }
        public void ConvertArabicToNumeral_WhenPassed5_ReturnsV()
        {
            const int    number   = 5;
            const string expected = "V";

            var result = ArabicConverter.ToNumeral(number);

            result.Should().Be(expected);
        }
        public void ConvertArabicToNumeral_WhenPassedANumberOverMaximum_Throws()
        {
            const int overMaximum = ArabicConverter.MaximumNumeralValue + 1;

            Assert.Throws <ArgumentOutOfRangeException>(() => ArabicConverter.ToNumeral(overMaximum));
        }
        public void ConvertArabicToNumeral_WhenPassedANumberUnderMinimum_Throws()
        {
            const int underMinimum = ArabicConverter.MinimumNumeralValue - 1;

            Assert.Throws <ArgumentOutOfRangeException>(() => ArabicConverter.ToNumeral(underMinimum));
        }