Ejemplo n.º 1
0
        public Boolean Equals(ICountProperty countProperty)
        {
            CountWithMax countWithMax = countProperty as CountWithMax;

            if (countWithMax == null)
            {
                return(false);
            }
            return(this.max == countWithMax.max);
        }
        public void CountWithMaxParserTest()
        {
            CountWithMax countWithMaxOf1     = new CountWithMax(1);
            CountWithMax countWithMaxOf83729 = new CountWithMax(83729);

            TestUtil.TestPropertyParser("0-1", countWithMaxOf1);
            TestUtil.TestPropertyParser("\t\t  0-1 \n\n \t", countWithMaxOf1);

            TestUtil.TestPropertyParser("0-83729", countWithMaxOf83729);
            TestUtil.TestPropertyParser("\t\t  0-83729 \n\n \t", countWithMaxOf83729);


            //
            // Test that it disallows CountWithMax(0)
            //
            #if DEBUG
            try
            {
                CountWithMax countWithMax = new CountWithMax(0);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(String.Format("Caught expected exception {0}", e));
            }
            #endif

            //
            // Test some larger Count with max
            //
            for (UInt32 i = 1; i < 1000000; i += 95416)
            {
                CountWithMax countWithMax = (CountWithMax)CountProperty.Parse("0-" + i.ToString());
                Assert.AreEqual(i, countWithMax.max);
            }
        }