Ejemplo n.º 1
0
        //---------------------------------------------------------------------------
        // Move a range's endpoint(s) relative to position of endpoint in another range
        //---------------------------------------------------------------------------
        internal void TS_MoveEndpointByRange(TextPatternRange callingRange, TextPatternRangeEndpoint endPoint, TextPatternRange targetRange, TextPatternRangeEndpoint targetEndPoint, MoveEPResults expectedResult, Type expectedException, CheckType checkType)
        {
            string msg = "MoveEndpointByRange(" + endPoint + ",targetRange," + targetEndPoint + ") returned ";
            int moveCount = 0;
            int actualResult = 0;
            TextPatternRange cloneOfRange = null;

            Comment("Validating expected result is " + Parse(expectedResult, expectedException));

            if (callingRange != null)
                Range_Clone(callingRange, ref cloneOfRange, null, checkType);

            // Move endPoint
            Range_MoveEndpointByRange(cloneOfRange, endPoint, targetRange, targetEndPoint, expectedException, checkType);

            if (expectedException != null)
                return; // we're done

            // verify location of end point that we moved...
            Range_CompareEndpoints(cloneOfRange, endPoint, targetRange, targetEndPoint, ref moveCount, null, checkType);

            // Evaluate the state of the callingRange
            if (expectedException != null)
                actualResult += (int)MoveEPResults.Exception;
            else
            {
                if (IsEmptyRange(cloneOfRange, checkType) == true)
                    actualResult += (int)MoveEPResults.EmptyRange;
                else
                    actualResult += (int)MoveEPResults.NonemptyRange;
            }

            // Were we a success? expected result and correct endpoint location
            if (((actualResult & ((int)expectedResult)) > 0) && (moveCount == 0))
                Comment(msg + Parse(expectedResult, expectedException) + " as expected");
            else
                ThrowMe(
                        checkType, msg + Parse(expectedResult, null) + ", expected " + Parse(expectedResult, expectedException));

            m_TestStep++;
        }
Ejemplo n.º 2
0
 /// ---------------------------------------------------------------------------
 /// <summary>Parses values for enum</summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(MoveEPResults value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
Ejemplo n.º 3
0
        internal void MoveEndpointByRangeHelper1(SampleText sampleText, TargetRangeType callingRangeType, TargetRangeType targetRangeType, MoveEPResults result1, MoveEPResults result2, MoveEPResults result3, MoveEPResults result4, Type expectedException)
        {
            TextPatternRange callingRange = null;
            TextPatternRange targetRange = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, true, CheckType.Verification);

            // Pre-Condition Createtarget range = <<targetRangeType>>
            TS_CreateRange(out targetRange, targetRangeType, callingRange, true, CheckType.Verification);

            // Call MoveEndpointByRange(Start,target range,Start) with result = <<result1>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.Start,
                                    targetRange, TextPatternRangeEndpoint.Start,
                                    result1, expectedException, CheckType.Verification);

            // Call MoveEndpointByRange(Start,target range,End  ) with result = <<result2>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.Start,
                                   targetRange, TextPatternRangeEndpoint.End,
                                   result2, expectedException, CheckType.Verification);

            // Call MoveEndpointByRange(End,  target range,Start) with result = <<result3>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.End,
                                   targetRange, TextPatternRangeEndpoint.Start,
                                   result3, expectedException, CheckType.Verification);

            // Call MoveEndpointByRange(End,  target range,End  ) with result = <<result4>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.End,
                                   targetRange, TextPatternRangeEndpoint.End,
                                   result4, expectedException, CheckType.Verification);
        }
Ejemplo n.º 4
0
 static public string Parse(MoveEPResults value, Type type)
 {
     switch (value)
     {
         case MoveEPResults.EmptyRange: return "verify result is EMPTY range";
         case MoveEPResults.NonemptyRange: return "verify result is NON-empty range";
         case MoveEPResults.Exception:
             if (type == null)
                 throw new ArgumentException("Can't have MoveEPResults.Exception with null Type y");
             return ParseEx1(type);
         default:
             throw new ArgumentException("Parse() has no support for " + ParseType(value));
     }
 }