Visual Basic (Declaration) | |
---|---|
Public Property ErrorLevel As Integer |
C# | |
---|---|
public int ErrorLevel {get; set;} |
Library/Library.Test/TestCmdInterpreter.cs
C# | Copy Code |
---|---|
string result; CommandInterpreter ci = new CommandInterpreter(DefaultCommands.Get | DefaultCommands.Set, new TestCommands()); result = Capture(ci, "Count 2"); Assert.AreEqual("1\r\n2", result); result = Capture(ci, "Count /backwards 2"); Assert.AreEqual("2\r\n1", result); result = Capture(ci, "Count 2 /backwards"); Assert.AreEqual("2\r\n1", result); result = Capture(ci, "Count -n:2 /backwards:true"); Assert.AreEqual("2\r\n1", result); result = Capture(ci, "Count 2 /t:a /t:b"); Assert.AreEqual("1 a\r\n2 b", result); //Argument not found: result = Capture(ci, "Count"); Assert.AreEqual("The value for number is required.", result); //Non-ApplicationExcpetion dumps stack: ci.ErrorLevel = 0; result = Capture(ci, "BlowUp false"); Assert.AreNotEqual(0, ci.ErrorLevel); Assert.IsTrue(result.Contains("System.Exception: BlowUp"), "Expected \"System.Exception: BlowUp\" in {0}", result); //ApplicationExcpetion dumps message only: ci.ErrorLevel = 0; result = Capture(ci, "BlowUp true"); Assert.AreNotEqual(0, ci.ErrorLevel); Assert.AreEqual("BlowUp", result); |
VB.NET | Copy Code |
---|---|
Dim result As String Dim ci As New CommandInterpreter(DefaultCommands.[Get] Or DefaultCommands.[Set], New TestCommands()) result = Capture(ci, "Count 2") Assert.AreEqual("1" & vbCr & vbLf & "2", result) result = Capture(ci, "Count /backwards 2") Assert.AreEqual("2" & vbCr & vbLf & "1", result) result = Capture(ci, "Count 2 /backwards") Assert.AreEqual("2" & vbCr & vbLf & "1", result) result = Capture(ci, "Count -n:2 /backwards:true") Assert.AreEqual("2" & vbCr & vbLf & "1", result) result = Capture(ci, "Count 2 /t:a /t:b") Assert.AreEqual("1 a" & vbCr & vbLf & "2 b", result) 'Argument not found: result = Capture(ci, "Count") Assert.AreEqual("The value for number is required.", result) 'Non-ApplicationExcpetion dumps stack: ci.ErrorLevel = 0 result = Capture(ci, "BlowUp false") Assert.AreNotEqual(0, ci.ErrorLevel) Assert.IsTrue(result.Contains("System.Exception: BlowUp"), "Expected ""System.Exception: BlowUp"" in {0}", result) 'ApplicationExcpetion dumps message only: ci.ErrorLevel = 0 result = Capture(ci, "BlowUp true") Assert.AreNotEqual(0, ci.ErrorLevel) Assert.AreEqual("BlowUp", result) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
CommandInterpreter ClassCommandInterpreter Members