示例#1
0
文件: AtWord.cs 项目: szyn33k/TWord
        public AtWord(Language language, CurrencySymbol currencySymbol, CurrencyOptions currencyOptions)
        {
            _currencySymbol  = currencySymbol;
            _currencyOptions = currencyOptions;

            _currencyTransformer = new CurrencyTransformerFactory().Create(language);
        }
        public void GenericCurrencyTransformer()
        {
            var options = new CurrencyOptions();

            Assert.Equal("one hundred dollars zero cents", _transformer.ToWords(100, _currency, options));
            Assert.Equal("one hundred dollars one cent", _transformer.ToWords(100.01m, _currency, options));
            Assert.Equal("one hundred dollars ten cents", _transformer.ToWords(100.1m, _currency, options));
            Assert.Equal("one hundred dollars fifty seven cents", _transformer.ToWords(100.57m, _currency, options));
        }
        public void GenericCurrencyTransformer_IntegerAndDecimalPartSeparator()
        {
            var options = new CurrencyOptions
            {
                IntegerAndDecimalPartSeparator = " and "
            };

            Assert.Equal("one hundred dollars and zero cents", _transformer.ToWords(100, _currency, options));
            Assert.Equal("one hundred dollars and one cent", _transformer.ToWords(100.01m, _currency, options));
            Assert.Equal("one hundred dollars and ten cents", _transformer.ToWords(100.1m, _currency, options));
            Assert.Equal("one hundred dollars and fifty seven cents", _transformer.ToWords(100.57m, _currency, options));
        }
        public void GenericCurrencyTransformer_IntegerPartOnly()
        {
            var options = new CurrencyOptions
            {
                IntegerPartOnly = true
            };

            Assert.Equal("one hundred dollars", _transformer.ToWords(100, _currency, options));
            Assert.Equal("one hundred dollars", _transformer.ToWords(100.01m, _currency, options));
            Assert.Equal("one hundred dollars", _transformer.ToWords(100.1m, _currency, options));
            Assert.Equal("one hundred dollars", _transformer.ToWords(100.57m, _currency, options));
        }
        public void GenericCurrencyTransformer_DecimalAsFraction()
        {
            var options = new CurrencyOptions
            {
                DecimalAsFraction = true
            };

            Assert.Equal("one hundred dollars 0/100 cents", _transformer.ToWords(100, _currency, options));
            Assert.Equal("one hundred dollars 1/100 cent", _transformer.ToWords(100.01m, _currency, options));
            Assert.Equal("one hundred dollars 10/100 cents", _transformer.ToWords(100.1m, _currency, options));
            Assert.Equal("one hundred dollars 57/100 cents", _transformer.ToWords(100.57m, _currency, options));
        }
示例#6
0
 public Currency(CurrencyOptions currencyOption)
 {
     this.currencyOption = currencyOption;
     this.fractionDigits = (int)RoundingMode.Default;
 }
示例#7
0
 public Currency(CurrencyOptions currencyOption, sbyte fractionDigits)
 {
     this.currencyOption = currencyOption;
     this.fractionDigits = fractionDigits;
 }
示例#8
0
 public AtWordBuilder()
 {
     _currencyOptions = new CurrencyOptions();
 }
示例#9
0
 public ValuesController(IOptions <CurrencyOptions> currencies, Lazy <ICurrencyProvider> provider)
 {
     _currencies = currencies.Value;
 }
示例#10
0
 public CurrenciesController(IOptions <CurrencyOptions> currencies)
 {
     _currencies = currencies.Value;
 }