예제 #1
0
        public void ConvertFrom_WithInvalidCharacters(string value, NumberSystem numberSystem)
        {
            // arrange

            // act - assert
            Assert.ThrowsAny <Exception>(() => NumberConversionStrategy.ConvertFrom(value, numberSystem));
        }
예제 #2
0
        public void ConvertFrom_WithValidValues(string value, NumberSystem numberSystem, int expectedResult)
        {
            // arrange

            // act
            var result = NumberConversionStrategy.ConvertFrom(value, numberSystem);

            // assert
            Assert.Equal(expectedResult, result);
        }
예제 #3
0
        public void Convert()
        {
            try
            {
                ErrorMessage = null;
                if (string.IsNullOrEmpty(EntryValue))
                {
                    throw new FormatException();
                }

                var valueAsInt = NumberConversionStrategy.ConvertFrom(EntryValue, EntryNumberSystem);
                ResultValue = NumberConversionStrategy.ConvertTo(valueAsInt, ResultNumberSystem);
            }
            catch
            {
                ErrorMessage = NumberConversionStrategy.GetNumberSystemErrorMessage(EntryNumberSystem);
            }
        }