Exemplo n.º 1
0
        private int GetPoemCount()
        {
            if (Ranges?.Count == 0)
            {
                return(0);
            }

            int n = 0;

            foreach (AlnumRange range in Ranges)
            {
                if (range.A == null)
                {
                    continue;                   // defensive
                }
                if (range.B != null)
                {
                    Alphanumeric start = Alphanumeric.Parse(range.A);
                    Alphanumeric end   = Alphanumeric.Parse(range.B);
                    if (!start.IsNull() && !end.IsNull() &&
                        start.Alpha == null && end.Alpha == null)
                    {
                        n += (int)end.Number - (int)start.Number;
                    }
                }
                else
                {
                    n++;
                }
            }
            return(n);
        }
Exemplo n.º 2
0
 public static void AlphanumericParserIncorrect()
 => AssertThat(() => Alphanumeric.Parse("-yz")).ThrowsExactlyException <ParseException>();
Exemplo n.º 3
0
 public static void AlphanumericParserCorrectNumerical()
 => AssertThat(Alphanumeric.Parse("987")).IsEqualTo('9');
Exemplo n.º 4
0
 public static void AlphanumericParserCorrectAlphabetical()
 => AssertThat(Alphanumeric.Parse("xyz")).IsEqualTo('x');