示例#1
0
        public string TrimEnd(string input, string endsWith, StringComparison comparisonType)
        {
            PexAssume.IsNotNull(input);
            PexAssume.IsNotNull(endsWith);

            string result = CommonStringExtensions.TrimEnd(input, endsWith, comparisonType);

            PexAssert.IsNotNull(result);
            PexAssert.IsTrue(result.Length <= input.Length);

            bool stillEndsWith      = result.EndsWith(endsWith, comparisonType);
            bool isEndsWithNotEmpty = endsWith.Length > 0;

            PexAssert.IsTrue(!stillEndsWith || !isEndsWithNotEmpty);

            return(result);
        }
示例#2
0
        public string TrimEnd(string input, string endsWith, StringComparison comparisonType, int max)
        {
            string result = CommonStringExtensions.TrimEnd(input, endsWith, comparisonType, max);

            PexAssert.IsNotNull(result);
            PexAssert.IsTrue(result.Length <= input.Length);

            bool isEndsWithNotEmpty = endsWith.Length > 0;

            if (isEndsWithNotEmpty)
            {
                int originalEndsWithCount = CommonStringExtensions.CountSubstringEnd(input, endsWith, comparisonType);
                int resultEndsWithCount   = CommonStringExtensions.CountSubstringEnd(result, endsWith, comparisonType);

                PexAssert.IsTrue(resultEndsWithCount == 0 ||
                                 resultEndsWithCount == originalEndsWithCount - max);
            }

            return(result);
        }