C# Class NStub.CSharp.ObjectGeneration.CodeMethodComposer

Provides helper methods for composition of CodeMemberMethod method members.
Exibir arquivo Open project: Jedzia/NStub Class Usage Examples

Public Methods

Method Description
AppendAssertInconclusive ( CodeMemberMethod codeMemberMethod, string inconclusiveText ) : void

Appends a 'Assert.Inconclusive("Text")' statement to the specified method.

CreateAndInitializeCollectionField ( string memberCollectionField ) : CodeAssignStatement

Creates a reference to a collection based member field and initializes it with a new instance of the specified parameter type and adds a collection item to it. Sample values are used as the initializing expression.

With a custom Type, this method produces a statement with a initializer like: this.paths = new[] { pathsItem };. where the item is defined like: this.pathsItem = new PathItemType();. myType of type System.Type: this.pathsItem = "An Item";.

CreateAndInitializeMemberField ( Type type, string memberField ) : CodeAssignStatement

Creates a reference to a member field and initializes it with a new instance of the specified parameter type. Sample values are used as the initializing expression.

With a custom Type, this method produces a statement with a initializer like: this.project = new Microsoft.Build.BuildEngine.Project();. or let myInt be of type int: this.myInt = 1234;. myType of type System.Type: this.myType = typeof(System.Object);.

CreateExpressionByType ( Type type, string memberField ) : System.CodeDom.CodeExpression
CreateTestStubForMethod ( CodeMemberMethod codeMemberMethod ) : void

Creates the stub for the specified code member method. This method actually implements the method body for the test method.

Method Details

AppendAssertInconclusive() public static method

Appends a 'Assert.Inconclusive("Text")' statement to the specified method.
public static AppendAssertInconclusive ( CodeMemberMethod codeMemberMethod, string inconclusiveText ) : void
codeMemberMethod System.CodeDom.CodeMemberMethod The code member method.
inconclusiveText string The warning parameter text of the Assert.Inconclusive call.
return void

CreateAndInitializeCollectionField() public static method

Creates a reference to a collection based member field and initializes it with a new instance of the specified parameter type and adds a collection item to it. Sample values are used as the initializing expression.
With a custom Type, this method produces a statement with a initializer like: this.paths = new[] { pathsItem };. where the item is defined like: this.pathsItem = new PathItemType();. myType of type System.Type: this.pathsItem = "An Item";.
public static CreateAndInitializeCollectionField ( string memberCollectionField ) : CodeAssignStatement
memberCollectionField string Name of the referenced collection field.
return System.CodeDom.CodeAssignStatement

CreateAndInitializeMemberField() public static method

Creates a reference to a member field and initializes it with a new instance of the specified parameter type. Sample values are used as the initializing expression.
With a custom Type, this method produces a statement with a initializer like: this.project = new Microsoft.Build.BuildEngine.Project();. or let myInt be of type int: this.myInt = 1234;. myType of type System.Type: this.myType = typeof(System.Object);.
public static CreateAndInitializeMemberField ( Type type, string memberField ) : CodeAssignStatement
type System.Type Defines the type of the new object.
memberField string Name of the referenced member field.
return System.CodeDom.CodeAssignStatement

CreateExpressionByType() public static method

public static CreateExpressionByType ( Type type, string memberField ) : System.CodeDom.CodeExpression
type System.Type
memberField string
return System.CodeDom.CodeExpression

CreateTestStubForMethod() public static method

Creates the stub for the specified code member method. This method actually implements the method body for the test method.
public static CreateTestStubForMethod ( CodeMemberMethod codeMemberMethod ) : void
codeMemberMethod System.CodeDom.CodeMemberMethod The code member method.
return void