c# 4.0 - Workflow Foundation - Literal only supports value types and the immutable type System.String -


i have following unit test wf code activity called mycodeactivity:

[expectedexception(typeof(argumentexception))] [testmethod] public void shouldrequireparam() {     //arrange     var invoker = new workflowinvoker(new mycodeactivity()     {         myint = 2,         mycomplexobject = _complexobject     });      //act     invoker.invoke();      //assert     assert.fail("expected argumentexception"); } 

when run test following exception

'literal< mycomplexobject>': literal supports value types , immutable type system.string. type mycomplexobject cannot used literal.

to fix immediate problem:

mycomplexobject = _complexobject 

to

mycomplexobject = new inargument<mycomplexobject>((ctx) => _complexobject) 

further reading : http://msdn.microsoft.com/en-us/library/ee358749.aspx .

note: should use microsoft.activities.unittesting package available on nuget. makes ioc alot easier (seeing wf works service locator pattern , not dependency injection)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -