public static string ConvertToWords(this INumberToWordsConverter converter, double number, Action <IConversionOptions> optionsBuilder)
        {
            if (converter is null)
            {
                throw new ArgumentNullException(nameof(converter));
            }

            if (optionsBuilder is null)
            {
                throw new ArgumentNullException(nameof(optionsBuilder));
            }

            var options = ConversionOptions.Default;

            optionsBuilder?.Invoke(options);
            return(converter.ConvertToWords(number, options));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CurrencyToWordsConverter"/> class.
 /// </summary>
 /// <param name="numberToWordsConverter">The number to words converter.</param>
 public CurrencyToWordsConverter(INumberToWordsConverter numberToWordsConverter)
 {
     this.NumberToWordsConverter = numberToWordsConverter;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PseudoNumberToWordsConverter"/> class.
 /// </summary>
 /// <param name="transformer">The <see cref="ITransformer"/> to use.</param>
 /// <param name="inner">The inner <see cref="INumberToWordsConverter"/> to use before applying transforms.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="transformer"/> or <paramref name="inner"/> is <see langword="null"/>.
 /// </exception>
 public PseudoNumberToWordsConverter(ITransformer transformer, INumberToWordsConverter inner)
 {
     Transformer = transformer ?? throw new ArgumentNullException(nameof(transformer));
     Inner       = inner ?? throw new ArgumentNullException(nameof(inner));
 }
Exemplo n.º 4
0
 private void WhenUserEnters__input__(String input)
 {
     _sut   = new NumberToWordsConverter();
     result = _sut.ConvertToWords(input);
 }
 private void WhenUserEntersInvalid__input__(String input)
 {
     _sut       = new NumberToWordsConverter();
     _exception = Should.Throw <Exception>(() => _sut.ConvertToWords(input));
 }
Exemplo n.º 6
0
 public HomeController(INumberToWordsConverter numberConverterService)
 {
     _numberConverterService = numberConverterService;
 }