public void ConvertFrom_WithInvalidCharacters(string value, NumberSystem numberSystem) { // arrange // act - assert Assert.ThrowsAny <Exception>(() => NumberConversionStrategy.ConvertFrom(value, numberSystem)); }
public void ConvertFrom_WithValidValues(string value, NumberSystem numberSystem, int expectedResult) { // arrange // act var result = NumberConversionStrategy.ConvertFrom(value, numberSystem); // assert Assert.Equal(expectedResult, result); }
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); } }