c# - Substitute property of local variable in Unit Tests -


i'm trying write simple unit test , have problem mocking/substitutes.

the method want test looks this:

public override void execute(object parameter)     {         var openfiledialogviewmodel = new openfiledialogviewmodel         {             addextension = true,             defaultextension = "xxx",             filter = "xxx files|*.xxx"         };          bool result = mfiledialogservice.openfile(openfiledialogviewmodel);          if (result)         {             mdatabaseloadingservice.loadfile(openfiledialogviewmodel.filename);         }     } 

for test want set filename, call execute method , check whether file loaded or not. in test used 'nsubstitute' tell 'openfile' method of 'filedialogservice' return true this:

mfiledialogservice.openfile(arg.any<iopenfiledialogviewmodel>()).returnsforanyargs(true) 

but how set 'filename' property of 'openfiledialogviewmodel'?


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -