ClipString() public static method

Clip a string to a given length, starting at a particular offset, returning the clipped string with ellipses representing the removed parts
public static ClipString ( string s, int maxStringLength, int clipStart ) : string
s string The string to be clipped
maxStringLength int The maximum permitted length of the result string
clipStart int The point at which to start clipping
return string
示例#1
0
        public static void TestClipString(string input, int max, int start, string result)
        {
#if !PORTABLE
            System.Console.WriteLine("input=  \"{0}\"", input);
            System.Console.WriteLine("result= \"{0}\"", result);
#endif
            Assert.That(MsgUtils.ClipString(input, max, start), Is.EqualTo(result));
        }
示例#2
0
 /// <summary>
 /// Write the constraint description to a MessageWriter
 /// </summary>
 /// <param name="writer">The writer on which the description is displayed</param>
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     writer.WritePredicate("String starting with");
     writer.WriteExpectedValue(MsgUtils.ClipString(expected, writer.MaxLineLength - 40, 0));
     if (this.caseInsensitive)
     {
         writer.WriteModifier("ignoring case");
     }
 }