public void ReadAgeOrRange_AgeWhitespacePercentage()
        {
            StringReader reader = new StringReader("66 ( 50% )\t");
            int          index;

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(66, 66);
            expectedPercentage = Percentage.Parse("50%");
            InputValue <AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);

            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(0, index);
            Assert.AreEqual('\t', reader.Peek());
        }
        public void ReadAgeOrRange_RangePercentage()
        {
            StringReader reader = new StringReader("30-75(10%)");
            int          index;

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(30, 75);
            expectedPercentage = Percentage.Parse("10%");
            InputValue <AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);

            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(0, index);
            Assert.AreEqual(-1, reader.Peek());
        }
        public void ReadAgeOrRange_RangeWhitespacePercentage()
        {
            StringReader reader = new StringReader(" 1-100 (22.2%)Hi");
            int          index;

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(1, 100);
            expectedPercentage = Percentage.Parse("22.2%");
            InputValue <AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);

            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(1, index);
            Assert.AreEqual('H', reader.Peek());
        }
        public void ReadAgeOrRange_Multiple()
        {
            StringReader reader = new StringReader(" 1-40 (50%)  50(65%)\t 65-70  71-107 ( 15% )  109");
            int          index;                   //0123456789_123456789_^123456789_123456789_12345678

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(1, 40);
            expectedPercentage = Percentage.Parse("50%");
            InputValue <AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);

            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(1, index);
            Assert.AreEqual(' ', reader.Peek());

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(50, 50);
            expectedPercentage = Percentage.Parse("65%");
            ageRange           = PartialThinning.ReadAgeOrRange(reader, out index);
            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(13, index);
            Assert.AreEqual('\t', reader.Peek());

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(65, 70);
            expectedPercentage = null;
            ageRange           = PartialThinning.ReadAgeOrRange(reader, out index);
            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(22, index);
            Assert.AreEqual('7', reader.Peek());

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(71, 107);
            expectedPercentage = Percentage.Parse("15%");
            ageRange           = PartialThinning.ReadAgeOrRange(reader, out index);
            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(29, index);
            Assert.AreEqual(' ', reader.Peek());

            eventHandlerCalled = false;
            expectedRange      = new AgeRange(109, 109);
            expectedPercentage = null;
            ageRange           = PartialThinning.ReadAgeOrRange(reader, out index);
            Assert.IsTrue(eventHandlerCalled);
            Assert.AreEqual(45, index);
            Assert.AreEqual(-1, reader.Peek());
        }