namespace <%= client %>.<%= package %>.UnitTests
{
using System;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Moq;
///
/// Base class for workflow activity tests.
///
/// The type of workflow activity.
public abstract class WorkflowActivityTests
where TCodeActivity : CodeActivity, new()
{
///
/// Initializes a new instance of the class.
///
public WorkflowActivityTests()
{
this.WorkflowActivity = new TCodeActivity();
this.WorkflowInvoker = new WorkflowInvoker(this.WorkflowActivity);
this.TracingSvcMock = new Mock();
this.OrgSvcFactoryMock = new Mock();
this.OrgSvcMock = new Mock();
this.WorkflowContextMock = new Mock();
this.OrgSvcFactoryMock.SetReturnsDefault(this.OrgSvcMock.Object);
this.WorkflowContextMock.Setup(workflowContext => workflowContext.UserId).Returns(Guid.NewGuid());
this.WorkflowContextMock.Setup(workflowContext => workflowContext.SharedVariables).Returns(new ParameterCollection());
this.WorkflowInvoker.Extensions.Add(this.WorkflowContextMock.Object);
this.WorkflowInvoker.Extensions.Add(this.TracingSvcMock.Object);
this.WorkflowInvoker.Extensions.Add(this.OrgSvcFactoryMock.Object);
this.WorkflowInvoker.Extensions.Add(this.OrgSvcMock.Object);
}
///
/// Gets the workflow invoker.
///
protected WorkflowInvoker WorkflowInvoker { get; }
///
/// Gets the workflow activity under test.
///
protected TCodeActivity WorkflowActivity { get; }
///
/// Gets mock workflow context.
///
protected Mock WorkflowContextMock { get; }
///
/// Gets the mocked tracing service.
///
protected Mock TracingSvcMock { get; }
///
/// Gets the mocked organization service factory.
///
protected Mock OrgSvcFactoryMock { get; }
///
/// Gets the mocked organization service.
///
protected Mock OrgSvcMock { get; }
}
}