示例#1
0
        public void GetQuantitativeNumber_return_not_empty_string(string expectedResult, int arg, SubjectiveCase subjective,
                                                                  Kind kind)
        {
            var result = Frac20.GetQuantitativeNumber(arg, x => x % 100, subjective, kind);

            Assert.AreEqual(expectedResult, result);
        }
        string ConvertNumberToWords(int val)
        {
            int num = val % 1000;

            if (0 == num)
            {
                return("");
            }
            if (num < 0)
            {
                throw new ArgumentOutOfRangeException("val", "Параметр не может быть отрицательным");
            }


            var hunds = Hunds.GetQuantitativeNumber(num, SubjectiveCaseNumber);

            if (!string.IsNullOrEmpty(hunds))
            {
                hunds = hunds.AddSpace();
            }
            StringBuilder r = new StringBuilder(hunds);

            if (num % 100 < 20)
            {
                r.Append(Frac20.GetQuantitativeNumber(num, x => x % 100, SubjectiveCaseNumber, NumberKind).AddSpace());
            }
            else
            {
                r.Append(Tens.GetQuantitativeNumber(num, SubjectiveCaseNumber).AddSpace());
                r.Append(Frac20.GetQuantitativeNumber(num, x => x % 10, SubjectiveCaseNumber, NumberKind).AddSpace());
            }

            return(r.ToString());
        }