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

Glossary Item Box

Gets/sets the exit code of the operation/process

Syntax

Visual Basic (Declaration) 
Public Property ErrorLevel As Integer
C# 
public int ErrorLevel {get; set;}

Example

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.NETCopy 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)

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys