public void SumProp_should_return_not_empty_string_within_thousand(string expectedResult, int arg, Kind kind, SubjectiveCase subjectiveCase) { var result = _rusNumber.SumProp(arg, kind, subjectiveCase); Assert.AreEqual(expectedResult, result); }
public void GetQuantitativeNumber_return_not_empty_string_for_100(string expectedResult, int number, SubjectiveCase subjectiveCase) { var result = Hunds.GetQuantitativeNumber(number, subjectiveCase); Assert.AreEqual(expectedResult, result); }
public void GetQuantitativeNumber_return_not_empty_string_for_1000(string expectedResult, int arg, SubjectiveCase subjective, string sourceString) { var result = sourceString.GetQuantitativeThousandNumber(arg, subjective); Assert.AreEqual(expectedResult, result); }
public void GetQuantitativeNumber_return_not_empty_string_for_50_80(string expectedResult, int arg, SubjectiveCase subjective) { var result = Tens.GetQuantitativeNumber(arg, subjective); Assert.AreEqual(expectedResult, result); }
public FormationThousands(Func <int, string> convertNumberToWords, SubjectiveCase subjectiveCase) { _thousandsFunc = new Dictionary <int, Func <int, string> > { { (int)DegreesThousand.Thousand, num => convertNumberToWords(num).GetQuantitativeThousandNumber(num, subjectiveCase) } }; }
public static string GetQuantitativeThousandNumber(this string val, int number, SubjectiveCase subjectiveCase = SubjectiveCase.Nominative) { int serialNumber = GetSerialNumber(number); if (string.IsNullOrEmpty(val)) { return(""); } return(string.Concat(val, DeclinationThousand[subjectiveCase]("тысяч", GetBitDepth(serialNumber)))); }
public static string GetQuantitativeNumber(int number, Func <int, int> funct, SubjectiveCase subjectiveCase = SubjectiveCase.Nominative, Kind kind = Kind.Masculine) { var index = funct(number); if (index >= 5 && index < 19) { return(Frac5_19[subjectiveCase](frac20Base[index])); } return(SpecialCaseFor1_4.Select(content => content.Index).Contains(index) ? SpecialCaseFor1_4 .Where(content => content.Index == index) .Where(content => content.Kind == kind || content.Kind == Kind.None) .Where(content => content.SubjCase == subjectiveCase) .Select(content => content.StrValue) .FirstOrDefault() : frac20Base[index]); }
public string SumProp(int val, Kind kind = Kind.None, SubjectiveCase subjectiveCase = SubjectiveCase.Nominative) { _numberKind = kind; SubjectiveCaseNumber = subjectiveCase; bool minus = false; if (val < 0) { val = -val; minus = true; } int n = val; StringBuilder r = new StringBuilder(); if (0 == n) { r.Append("0".AddSpace()); } if (n % 1000 != 0) { r.Append(ConvertNumberToWords(n)); } var formation = new FormationThousands(ConvertNumberToWords, subjectiveCase); formation.GetConvertSamplesInWords(ref r, n); //TODO: нет реализации для степеней больше тысячи if (minus) { r.Insert(0, "минус "); } r[0] = char.ToUpper(r[0]); return(r.ToString()); }
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); }
public RusNumber(Kind kind = Kind.None, SubjectiveCase subjectiveCase = SubjectiveCase.Nominative) { _numberKind = kind; SubjectiveCaseNumber = subjectiveCase; }
public static string GetQuantitativeNumber(int number, SubjectiveCase subjectiveCase) { var index = GetSerialNumber(number); return(DictHunds[index](subjectiveCase, index)); }