c# - Rhino Mock Stubbing method with ExpandoObject as parameter -


i want unit test method under test calls stubbed object , method right parameters. problem 1 of parameters dynamic (expandoobject). if "data" (variable below) typed object works expected.

    ...     [test]     public void methodtest_whensomething_expectresult()     {       ...       dynamic data = new expandoobject();       data.id = param1;       data.name = param2;       var myclass= mockrepository.generatestub<imyclass>();       myclass.stub(x => x.mymethod("hello", data).returns(expectedresult);       ...       var actualresult = anotherclass.methodundertest(param1, param2);        assert.isnotnull(actualresult);     } 

any ideas how can this? btw, dont want "ignorearguments" testing right params being passed in.

tia

i assume need define stub returns expectedresult when the second parameter has right values in fields id , name.

but stub defined return expectedresult when the second parameter same data object.

if so, need modify stub definition:

myclass     .stub(x => x.mymethod(             arg<string>.is.equal("hello"),             arg<idictionary<string, object>>.matches(d => d["id"].equals(param1) && d["name"].equals(param2))         ))     .return(expectedresult); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -