public void InterpretAsRangeAllStr_UppercaseVersionOfRangeAllString_ReturnsTrue()
        {
            bool stringIsRangeAllStr =
                EntryFieldInterpretingUtils.InterpretAsRangeAllStr(MssMsgUtil.RANGE_ALL_STR.ToUpper());

            Assert.IsTrue(stringIsRangeAllStr);
        }
        public void InterpretAsInt_DecimalInput_CannotExtractInt()
        {
            int  outValue;
            bool successfullyInturpreted = EntryFieldInterpretingUtils.InterpretAsInt("1.5", out outValue);

            Assert.IsFalse(successfullyInturpreted);
        }
        public void InterpretAsInt_NonIntegerString_CannotExtractInt()
        {
            int  outValue;
            bool successfullyInturpreted = EntryFieldInterpretingUtils.InterpretAsInt("1b", out outValue);

            Assert.IsFalse(successfullyInturpreted);
        }
        public void InterpretAsInt_ValidIntegerWithWhitespace_SuccessfullyExtractsInt()
        {
            int  outValue;
            bool successfullyInturpreted = EntryFieldInterpretingUtils.InterpretAsInt("  12  ", out outValue);

            Assert.IsTrue(successfullyInturpreted);
            Assert.AreEqual(12, outValue);
        }
        public void InterpretAsInt_ValidInteger_SuccessfullyExtractsInt()
        {
            int  outValue;
            bool successfullyInturpreted = EntryFieldInterpretingUtils.InterpretAsInt("25", out outValue);

            Assert.IsTrue(successfullyInturpreted);
            Assert.AreEqual(25, outValue);
        }
        public void InterpretAsRangeOfInts_SingleInteger_ReturnsFalse()
        {
            int  outRangeTop;
            int  outRangeBottom;
            bool successfullyInturpreted =
                EntryFieldInterpretingUtils.InterpretAsRangeOfInts("9", out outRangeTop, out outRangeBottom);

            Assert.IsFalse(successfullyInturpreted);
        }
        public void InterpretAsRangeOfInts_RangeWithDecimal_ReturnsFalse()
        {
            int  outRangeTop;
            int  outRangeBottom;
            bool successfullyInturpreted =
                EntryFieldInterpretingUtils.InterpretAsRangeOfInts("10.3-15", out outRangeTop, out outRangeBottom);

            Assert.IsFalse(successfullyInturpreted);
        }
        public virtual bool GetRangeFromUserInput(string userInput, int minValue, int maxValue,
                                                  out int rangeBottom, out int rangeTop, out string errorMsg)
        {
            int singleRangeValue;
            int tempRangeTop;
            int tempRangeBottom;

            errorMsg = "";
            bool validFormat;
            bool validRange;

            if (EntryFieldInterpretingUtils.InterpretAsInt(userInput, out singleRangeValue))
            {
                rangeTop    = singleRangeValue;
                rangeBottom = singleRangeValue;
                validFormat = true;
            }
            else if (EntryFieldInterpretingUtils.InterpretAsRangeAllStr(userInput))
            {
                rangeTop    = maxValue;
                rangeBottom = minValue;
                validFormat = true;
            }
            else if (EntryFieldInterpretingUtils.InterpretAsRangeOfInts(userInput, out tempRangeTop, out tempRangeBottom))
            {
                rangeTop    = tempRangeTop;
                rangeBottom = tempRangeBottom;
                validFormat = true;
            }
            else
            {
                errorMsg    = "Invalid range format";
                rangeTop    = MssMsgUtil.UNUSED_MSS_MSG_DATA;
                rangeBottom = MssMsgUtil.UNUSED_MSS_MSG_DATA;
                validFormat = false;
            }

            if (validFormat == true)
            {
                if (rangeBottom >= minValue && rangeTop <= maxValue)
                {
                    validRange = true;
                }
                else
                {
                    errorMsg   = "Out of range";
                    validRange = false;
                }
            }
            else
            {
                validRange = false;
            }

            return(validRange);
        }
        public void InterpretAsRangeOfInts_BackwardsIntegerRange_SuccessfullyAssignSmallerNumberToRangeBottomAndLargerNumberToRangeTop()
        {
            int  outRangeTop;
            int  outRangeBottom;
            bool successfullyInturpreted =
                EntryFieldInterpretingUtils.InterpretAsRangeOfInts("85-6", out outRangeTop, out outRangeBottom);

            Assert.IsTrue(successfullyInturpreted);
            Assert.AreEqual(6, outRangeBottom);
            Assert.AreEqual(85, outRangeTop);
        }
        public void InterpretAsRangeOfInts_ValidIntegerRange_SuccessfullyExtractsRange()
        {
            int  outRangeTop;
            int  outRangeBottom;
            bool successfullyInturpreted =
                EntryFieldInterpretingUtils.InterpretAsRangeOfInts("10 - 20", out outRangeTop, out outRangeBottom);

            Assert.IsTrue(successfullyInturpreted);
            Assert.AreEqual(10, outRangeBottom);
            Assert.AreEqual(20, outRangeTop);
        }
        public void InterpretAsRangeAllStr_NonRangeAllString_ReturnsFalse()
        {
            bool stringIsRangeAllStr = EntryFieldInterpretingUtils.InterpretAsRangeAllStr("16");

            Assert.IsFalse(stringIsRangeAllStr);
        }