Represents a plural rule that will evaluate a given number using an abstract syntax tree generated by a plural rule formula parser.
Наследование: IPluralRule
Пример #1
0
        public void ParseCompleteRulesTest()
        {
            var parser = new AstTokenParser();
            foreach (object[] mapping in GetParseCompleteRulesTestData())
            {
                var astRoot = parser.Parse((string)mapping[0]);
                var rule = new AstPluralRule(100, astRoot);
                var expectedSeq = (string)mapping[1];

                for (int i = 0; i < 200; i++)
                {
                    var expected = int.Parse(expectedSeq[i].ToString());
                    Assert.Equal(expected, rule.Evaluate(i));
                }
            }
        }
Пример #2
0
 public void ParseRulesTest()
 {
     var parser = new AstTokenParser();
     foreach (object[] mapping in GetParseRulesTestData())
     {
         var astRoot = parser.Parse((string)mapping[1]);
         var rule = new AstPluralRule(100, astRoot);
         Assert.Equal((int)mapping[2], rule.Evaluate(0));
     }
 }