CSharpTest.Net
FilterPrecedence Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : FilterPrecedence Property

Glossary Item Box

Defines the filter precedence by appearance order of key character

Syntax

Visual Basic (Declaration) 
Public Property FilterPrecedence As String
C# 
public string FilterPrecedence {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C#Copy Code
string tempPath = Path.GetTempFileName();
string tempPath2 = Path.GetTempFileName();
try
{
    string result;
    CommandInterpreter ci = new CommandInterpreter(
        DefaultCommands.Find | DefaultCommands.PipeCommands | DefaultCommands.IORedirect,
        new TestCommands());

    //Redirect output:
    result = Capture(ci, "Count 100 > " + tempPath);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual(100, File.ReadAllLines(tempPath).Length);

    result = Capture(ci, "Find \"1\" -f:" + tempPath + " |Find \"0\" > " + tempPath2);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual("10\r\n100", File.ReadAllText(tempPath2).Trim());

    //Redirect input:
    result = Capture(ci, "Find \"1\" |Find \"0\" <" + tempPath + " >" + tempPath2);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual("10\r\n100", File.ReadAllText(tempPath2).Trim());

    //Change precedence and watch it fail:
    Assert.IsTrue(ci.FilterPrecedence.StartsWith("<") || ci.FilterPrecedence.StartsWith(">"));
    ci.FilterPrecedence = ci.FilterPrecedence.TrimStart('<', '>');

    result = Capture(ci, "Find \"1\" |Find \"0\" <" + tempPath + " >" + tempPath2);
    Assert.AreEqual(String.Empty, result);
    result = File.ReadAllText(tempPath2).Trim();
    Assert.AreEqual("10\r\n20\r\n30\r\n40\r\n50\r\n60\r\n70\r\n80\r\n90\r\n100", result);
}
finally
{
    File.Delete(tempPath);
    File.Delete(tempPath2);
}
VB.NETCopy Code
Dim tempPath As String = Path.GetTempFileName()
Dim tempPath2 As String = Path.GetTempFileName()
Try
    Dim result As String
    Dim ci As New CommandInterpreter(DefaultCommands.Find Or DefaultCommands.PipeCommands Or DefaultCommands.IORedirect, New TestCommands())

    'Redirect output:
    result = Capture(ci, "Count 100 > " + tempPath)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual(100, File.ReadAllLines(tempPath).Length)

    result = Capture(ci, "Find ""1"" -f:" + tempPath + " |Find ""0"" > " + tempPath2)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual("10" & vbCr & vbLf & "100", File.ReadAllText(tempPath2).Trim())

    'Redirect input:
    result = Capture(ci, "Find ""1"" |Find ""0"" <" + tempPath + " >" + tempPath2)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual("10" & vbCr & vbLf & "100", File.ReadAllText(tempPath2).Trim())

    'Change precedence and watch it fail:
    Assert.IsTrue(ci.FilterPrecedence.StartsWith("<") OrElse ci.FilterPrecedence.StartsWith(">"))
    ci.FilterPrecedence = ci.FilterPrecedence.TrimStart("<"C, ">"C)

    result = Capture(ci, "Find ""1"" |Find ""0"" <" + tempPath + " >" + tempPath2)
    Assert.AreEqual([String].Empty, result)
    result = File.ReadAllText(tempPath2).Trim()
    Assert.AreEqual("10" & vbCr & vbLf & "20" & vbCr & vbLf & "30" & vbCr & vbLf & "40" & vbCr & vbLf & "50" & vbCr & vbLf & "60" & vbCr & vbLf & "70" & vbCr & vbLf & "80" & vbCr & vbLf & "90" & vbCr & vbLf & "100", result)
Finally
    File.Delete(tempPath)
    File.Delete(tempPath2)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys