Exemplo n.º 1
0
        public void When_user_inputs_zero()
        {
            var number    = "0";
            var converter = new RomanConverter();
            var error     = new System.Exception("Number cannot be zero.");

            Assert.Throws(typeof(System.Exception), () => converter.ConvertToRomanNumeral(number));
        }
Exemplo n.º 2
0
        public void GetNumeralValue_GivenNumeralAsChar_ReturnsValueAsInt(char numeral, int expected)
        {
            RomanConverter converter = new RomanConverter();

            int actual = converter.GetNumeralValue(numeral);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 3
0
        public void InputNumberInString()
        {
            //arrange
            string str = RomanConverter.input = "1234";

            //assert
            Assert.ThrowsException <ArgumentException>(() => RomanConverter.CheckInputString(str));
        }
Exemplo n.º 4
0
        public void Convert_WhenGiven0_ReturnsEmptyString(int input, string expected)
        {
            RomanConverter converter = new RomanConverter();

            string actual = converter.Convert(input);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 5
0
        public void CountNumeral_GivenNumeralAndRemainingValue_ReturnsNumeralCount(char numeral, int remainingValue, int expected)
        {
            RomanConverter converter = new RomanConverter();

            int actual = converter.CountNumeral(numeral, remainingValue);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 6
0
        public void InputSymbolsValueInString()
        {
            //arrange
            string str = RomanConverter.input = "/-";

            //assert
            Assert.ThrowsException <ArgumentException>(() => RomanConverter.CheckInputString(str));
        }
Exemplo n.º 7
0
        public void InputPunctuationInString()
        {
            //arrange
            string str = RomanConverter.input = ",.?";

            //assert
            Assert.ThrowsException <ArgumentException>(() => RomanConverter.CheckInputString(str));
        }
Exemplo n.º 8
0
        public void ArgumentOutOfRange()
        {
            //arrange
            string str = RomanConverter.input = "MMMM";

            //assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => RomanConverter.RomanToInt(str));
        }
Exemplo n.º 9
0
        public void InputCyrillicInString()
        {
            //arrange
            string str = RomanConverter.input = "привет";

            //assert
            Assert.ThrowsException <ArgumentException>(() => RomanConverter.CheckInputString(str));
        }
        public void Test1ToRoman(string expected, int number)
        {
            var reader         = new TestConsoleReader(number);
            var userInput      = new UserInput(reader);
            var romanConverter = new RomanConverter(userInput);

            Assert.Equal(expected, romanConverter.ToRomanNumeral(number));
        }
Exemplo n.º 11
0
        private void AssertRomanNumber(string romanNumber, int expected)
        {
            var result = RomanConverter.Convert(romanNumber);

            if (result != expected)
            {
                Assert.Fail("Le chiffre " + romanNumber + " donne " + result.ToString(CultureInfo.InvariantCulture) + ". attendu : " + expected);
            }
        }
Exemplo n.º 12
0
        public void When_Number_Is_Given_Should_Return_Roman_Number(string number, string expected)
        {
            Numeric        testNumber     = new Numeric(number);
            RomanConverter romanConverter = new RomanConverter();

            var convertedValue = romanConverter.ToRoman(testNumber.Number);

            convertedValue.Should().BeEquivalentTo(expected);
        }
Exemplo n.º 13
0
        public void TestConversion()
        {
            RomanConverter converter = new RomanConverter();

            Assert.AreEqual <double>(converter.ToDecimal("MCMXLIV").Value, 1944);
            Assert.AreEqual <double>(converter.ToDecimal("DXXI").Value, 521);
            Assert.AreEqual <double>(converter.ToDecimal("CMXCII").Value, 992);
            Assert.AreNotEqual <double>(converter.ToDecimal("IV").Value, 6);
        }
Exemplo n.º 14
0
        public void ConversionTest()
        {
            RomanConverter converter = new RomanConverter();

            Assert.Equal <double>(1945, converter.ConvertToDecimal("MCMXLIVI").Value);
            Assert.Equal <double>(521, converter.ConvertToDecimal("DXXI").Value);
            Assert.Equal <double>(992, converter.ConvertToDecimal("CMXCII").Value);
            Assert.NotEqual <double>(6, converter.ConvertToDecimal("IV").Value);
        }
Exemplo n.º 15
0
        public void Should_ReturnNum_EvenWithLowerCaseParams(string romanNum, int ans)
        {
            //Given
            //When
            int integerNum = RomanConverter.ConvertRoman(romanNum);

            //Then
            integerNum.Should().Be(ans);
        }
Exemplo n.º 16
0
        public void Should_ReturnSubtractionOfNumerals(string romanNum, int answer)
        {
            //Given
            //When
            int integerNum = RomanConverter.ConvertRoman(romanNum);

            //Then
            integerNum.Should().Be(answer);
        }
Exemplo n.º 17
0
        public void Should_ThrowException_WhenGivenInvalidInput(string romanNum)
        {
            //Given
            //When
            Action action = () => RomanConverter.ConvertRoman(romanNum);

            //Then
            action.Should().Throw <KeyNotFoundException>();
        }
Exemplo n.º 18
0
 public void ConvertsRepeatedAndSubtracted()
 {
     Assert.AreEqual(19, RomanConverter.ToArabic("XIX"));
     Assert.AreEqual(29, RomanConverter.ToArabic("XXIX"));
     Assert.AreEqual(190, RomanConverter.ToArabic("CXC"));
     Assert.AreEqual(290, RomanConverter.ToArabic("CCXC"));
     Assert.AreEqual(1900, RomanConverter.ToArabic("MCM"));
     Assert.AreEqual(2900, RomanConverter.ToArabic("MMCM"));
 }
Exemplo n.º 19
0
 public void ConvertsAllSubtractedRomanToArabic()
 {
     Assert.AreEqual(4, RomanConverter.ToArabic("IV"));
     Assert.AreEqual(9, RomanConverter.ToArabic("IX"));
     Assert.AreEqual(40, RomanConverter.ToArabic("XL"));
     Assert.AreEqual(90, RomanConverter.ToArabic("XC"));
     Assert.AreEqual(400, RomanConverter.ToArabic("CD"));
     Assert.AreEqual(900, RomanConverter.ToArabic("CM"));
 }
Exemplo n.º 20
0
        public void Entering_the_Roman_Numeral_I_Results_in_number_1()
        {
            var romanNumeral   = "I";
            var romanConverter = new RomanConverter();

            var result = romanConverter.Convert(romanNumeral);

            Assert.AreEqual(1, result);
        }
        public void TestRomanConverter()
        {
            RomanConverter converter = new RomanConverter();

            Assert.Equal <double>(24, converter.ToDecimal("XXIV").Value);
            Assert.Equal <double>(247, converter.ToDecimal("CCXLVII").Value);
            Assert.Equal <double>(784, converter.ToDecimal("DCCLXXXIV").Value);
            Assert.Equal <double>(2421, converter.ToDecimal("MMCDXXI").Value);
        }
        public void TestConversion()
        {
            RomanConverter converter = new RomanConverter();

            Assert.Equal <double>(1944, converter.ToDecimal("MCMXLIV").Value);
            Assert.Equal <double>(521, converter.ToDecimal("DXXI").Value);
            Assert.Equal <double>(992, converter.ToDecimal("CMXCII").Value);
            Assert.Equal <double>(4, converter.ToDecimal("IV").Value);
        }
Exemplo n.º 23
0
        public void ConvertNumber_NumberOne_I()
        {
            var data      = 1;
            var wanted    = "I";
            var converter = new RomanConverter();

            var result = converter.ConvertNumber(data);

            Assert.AreEqual(wanted, result);
        }
Exemplo n.º 24
0
        public void ConvertNumber_NumberZero_Cero()
        {
            var data      = 0;
            var wanted    = "Cero";
            var converter = new RomanConverter();

            var result = converter.ConvertNumber(data);

            Assert.AreEqual(wanted, result);
        }
Exemplo n.º 25
0
        public void ConvertNumber_Number35_XXXV()
        {
            var data      = 23;
            var wanted    = "XXIII";
            var converter = new RomanConverter();

            var result = converter.ConvertNumber(data);

            Assert.AreEqual(wanted, result);
        }
Exemplo n.º 26
0
        public void ConvertNumber_Number2017_MMXVII()
        {
            var data      = 2017;
            var wanted    = "MMXVII";
            var converter = new RomanConverter();

            var result = converter.ConvertNumber(data);

            Assert.AreEqual(wanted, result);
        }
Exemplo n.º 27
0
        public void convert_a_number_to_a_roman_numeral(int input, string expectedResult)
        {
            //Arrange
            var converter = new RomanConverter();
            //Act
            var result = converter.IntToRoman(input);

            //Assert
            Assert.Equal(expectedResult, result);
        }
Exemplo n.º 28
0
        public void InputMMCMXCIX()
        {
            // arrange
            string res = "MMCMXCIX";
            // act
            int actual = RomanConverter.RomanToInt(res);

            // assert
            Assert.AreEqual(2999, actual);
        }
Exemplo n.º 29
0
        public void TestRomanConverter()
        {
            RomanConverter converter = new RomanConverter();

            Assert.Equal <double>(1944, converter.ToDecimal("MCMXLIV").Value);
            Assert.Equal <double>(39, converter.ToDecimal("XXXIX").Value);
            Assert.Equal <double>(246, converter.ToDecimal("CCXLVI").Value);
            Assert.Equal <double>(789, converter.ToDecimal("DCCLXXXIX").Value);
            Assert.Equal <double>(2421, converter.ToDecimal("MMCDXXI").Value);
        }
Exemplo n.º 30
0
        public void convert_a_roman_numeral_to_an_integer(int expectedResult, string input)
        {
            //Arrange
            var converter = new RomanConverter();
            //Act
            var result = converter.RomanToInt(input);

            //Assert
            Assert.Equal(expectedResult, result);
        }
 public void Setup()
 {
     this._RomanConverter = new RomanConverter();
 }