Learn About Microsoft .NET Framework 3.5

  BackBy Certification Magazine —

1 | 2 | 3 | 4 |

These questions are based on 70-504: TS: Microsoft .NET Framework 3.5 - Windows Workflow Foundation (C# .NET).

A Self Test Software Practice Test

Objective: Create and host workflows.
Sub-objective: Create state machine workflows.

Single answer, multiple-choice

You are designing a Windows Workflow Foundation (WF) application using the Microsoft .NET Framework 3.5. The WF application will use a state machine workflow that represents customer accounts. A customer account can be in one of the following states:

•    Created: Initial state for new customers.   
•    Active: Customer can use the account for new purchases.   
•    Inactive: Customers can view their purchase history but cannot make new purchases.   
•    Canceled: Customers cannot make purchases or view purchase history, and all information associated with that account is removed.

Which code should you use to create and add these state activities to the workflow?

A.    public enum CustomerAccountState {
     Created, Active, Inactive, Cancelled
}

public class CustomerAccountStateMachineWorkflow :
  StateMachineWorkflow {
     public CustomerAccountStateMachineWorkflow () {
          this.States.Add( CustomerAccountState.Created );
          this.States.Add( CustomerAccountState.Active );
          this.States.Add( CustomerAccountState.Inactive );
          this.States.Add( CustomerAccountState.Cancelled );
     }
}
B.    public class CustomerAccountStateMachineWorkflow :
  StateMachineWorkflow {
     private StateActivity created = new StateActivity();
     private StateActivity active = new StateActivity();
     private StateActivity inactive = new StateActivity();
     private StateActivity cancelled = new StateActivity();
     public CustomerAccountStateMachineWorkflow () {
          this.Activities.Add( created );
          this.Activities.Add( active );
          this.Activities.Add( inactive );
          this.Activities.Add( cancelled );
     }
}
C.    public class CustomerAccountStateMachineWorkflow :
  StateMachineWorkflowActivity {
     private StateActivity created = new StateActivity();
     private StateActivity active = new StateActivity();
     private StateActivity inactive = new StateActivity();
     private StateActivity cancelled = new StateActivity();
     public CustomerAccountStateMachineWorkflow () {
          this.Activities.Add( created );
          this.Activities.Add( active );
          this.Activities.Add( inactive );
          this.Activities.Add( cancelled );
     }
}
D.    public enum CustomerAccountState {
     Created, Active, Inactive, Cancelled
}

public class CustomerAccountStateMachineWorkflow :
  StateMachineWorkflowActivity {
     public CustomerAccountStateMachineWorkflow () {
          this.States.Add( CustomerAccountState.Created );
          this.States.Add( CustomerAccountState.Active );
          this.States.Add( CustomerAccountState.Inactive );
          this.States.Add( CustomerAccountState.Cancelled );
     }
}

Answer:
C

Tutorial:
To create and add the required state activities to the state machine workflow, you should use the following code:

public class CustomerAccountStateMachineWorkflow :
  StateMachineWorkflowActivity {
     private StateActivity created = new StateActivity();
     private StateActivity active = new StateActivity();
     private StateActivity inactive = new StateActivity();
     private StateActivity cancelled = new StateActivity();
     public CustomerAccountStateMachineWorkflow () {
          this.Activities.Add( created );
          this.Activities.Add( active );
          this.Activities.Add( inactive );
          this.Activities.Add( cancelled );
     }
}

To create a state machine workflow, you should first create a class derived from the StateMachineWorkflowActivity class. Next, create a StateActivity object for each state and set the Name property of each StateActivity object to identify the object within the workflow. Then, within the constructor of the workflow, you should add each StateActivity object to the Activities collection by using the Add method.

You should not use the code segments that use an enumeration for each state because you must create StateActivity objects to add them to the Activities collection of a state machine workflow. If you use these code segments, they will not compile.

You should not use the code segment that has the workflow class to derive from the StateMachineWorkflow class because no such class exists. To create a state machine workflow, you should derive from the StateMachineWorkflowActivity class.

References:

MSDN Library > .NET Framework 3.5 > Windows Workflow Foundation > Windows Workflow Foundation Programming Guide > Developing Workflows > Workflow Authoring Styles > State Machine Workflows

MSDN Library > .NET Framework Class Library > System.Workflow.Activities Namespace > StateMachineWorkflowActivity Class

Objective: Communicate with workflows.
Sub-objective: Consume services from a workflow.

Single answer, multiple-choice

Using the Microsoft .NET 3.5 Framework, you develop a Windows Workflow Foundation (WF) application that handles account transfers, withdrawals and deposits between regional bank branches. You have developed a sequential workflow to verify and apply all pending transactions for each bank within the region.

Account information and actions are provided by a Web service located in an extranet shared between bank branches. You use the Web service in the workflow to apply all wire transfers at the end of the day. (Click the Exhibit(s) button.)

You need to ensure that the InvokeDebitWS and InvokeCreditWS activities use the same proxy instance when processing a wire transfer. However, a unique session should be created for each wire transfer.

1 | 2 | 3 | 4 |
Viewed 9412 times.
SPONSORED LINKS