Unit testing asynchronous workflow activities

In a previous blog post I demonstrated how TypeMock allowed us to mock out the workflow runtime infrastructure and create true unit tests for a workflow activity. Now this may not seems like a big deal but because most of the classes in the workflow runtime are sealed mocking them with another mocking framework is pretty much impossible. Now you can test custom activities by wrapping them in a test workflow, creating a workflow runtime, running the workflow and inspecting the result I can hardly call this a unit test as we have to create lots of, complex, depended objects. … Continue reading Unit testing asynchronous workflow activities

Changing the ActivityDesignerTheme on an activity

Using an ActivityDesignerTheme is a quick way to customize the appearance of an activity in the workflow designer. But there is a gotcha [:(] Because once you applied the theme and have a workflow with the custom activity open in the designer no matter what you do changes will not be applied. I am not sure why this is but I suppose the designer caches the color scheme and doesn’t see any changes made to it. Take the following activity:using System; using System.ComponentModel; using System.Drawing; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Drawing.Drawing2D; namespace WorkflowConsoleApplication4 { [Designer(typeof(MyActivity1ActivityDesigner))] public partial class MyActivity: Activity … Continue reading Changing the ActivityDesignerTheme on an activity

Using multiple SetState activities in a StateMachineWorkflow

When working with state machine workflow’s the SetStateActivity is one of the more important activities to use. The main reason is that is the one used to transition from one state to another. You can actually transition state in a different way as well using the StateMachineWorkflowInstance.SetState() function but the SetStateActivity is by far the most often used. One of the cool features of the SetStateActivity that may not be immediately obvious is the fact that it doesn’t do the state switch immediately. Instead it saved the new target start in an internal property, named NextStateName on the StateMachineExecutionState type … Continue reading Using multiple SetState activities in a StateMachineWorkflow

ClickOnce certificate expiration

I just heard about a pretty nasty “bug” with ClickOnce. Well it isn’t an actual bug but still a nasty problem to run into. The problem is actually with the certificate used to sign a ClickOnce installer. When you create a new ClickOnce installer Visual Studio will automatically generate the required certificate for you. And the intention was that this was only a temporary certificate and that a developer would replace it with a real one. Now it turns out that most people, including me, think there is only a single advantage to using a real and that is the … Continue reading ClickOnce certificate expiration

Unit testing custom workflow activities

Most people consider unit testing of custom workflow activities to pretty much impossible. Sure you can create a dummy test workflow containing your new activity, new up a WorkflowRuntime, create a WorkflowInstance and start it. But just think about all the dependencies here with the extra dummy workflow and the complete WorkflowRuntime with all its dependencies. Hardly a unit test for an activity but more like an integration test. Now there is nothing wrong with integration tests, they are very useful and necessary, but they do not give the speedy and dynamic test coverage you expect and need from a … Continue reading Unit testing custom workflow activities