c# - How do you create an echoing mock using Moq? -


I'm making a fake for my ITransformer interface.

  public interface iTransformer {string transformation (string input); }  

I can make a duplicate that gives a given string based on specific input:

  var mock = new mock & lt; ITransformer & gt; (); Counterfeit. Setup (S = & gt; s.Transform ("foo")). Return ("bar");  

What I would like to do, to make a duplicate with a conversion () method, copy whatever gets passed to it. How would I go about doing this? Is this also possible?

I realized that the way my question is competing and usually the mock is to work, because I am not specifying a specific hope.

I also know that I can easily make my own class to do this, but I had the hope of using normal situations without defining the new class every time.

new copy = new fake & lt; ITransformer & gt; (); Counterfeit. Setup (T = & gt; T. TransformForm (This is any such & lt; string & gt; ()) Returns (String s) = & gt; s);

Whatever was supplied to this method should be resized back.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -