コード例 #1
0
        public void ConvertTo_WithValidValues(int value, NumberSystem numberSystem, string expectedResult)
        {
            // arrange

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

            // assert
            Assert.Equal(expectedResult, result);
        }
コード例 #2
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);
            }
        }