title: Rhino Mocks changing the body of method during unit test c#
body: <p>So the problem is as follows. I am unit testing a class SampleClass using Rhino Mocks 3.6. For the tests I use a mock of InnerClass as it is used in the SampleClass constructor. InnerClass has a method called TheMethod(ref string s1,ref string s2). Here is where the problem begins. TheMethod(ref string,ref string) is doing nothing with the parameters and I want TheMethod to actually modify one of the strings (s1). Is it possible, using Rhino Mocks, to do such thing? If so, then how? WhenCalled? Do() handler? I'm clueless. Here's the pseudocode</p>
  
  <pre><code>Class SampleClass
  {
  Public String SampleClassMethod()
  {
    string s1 = string.Empty;
    string s2 = string.Empty;
    string s_final = this.InnerClass.TheMethod(ref s1, ref s2); //TheMethod() which is doing 
                                                     //nothing with the given strings
    if (s_final == "something")
    return s1;
  }
  }
  </code></pre>
  
  <p>The result is, that s1 is unchanged and for the testing reasons I would like the TestMethod() to modify s1's value WITHOUT changing the body of TheMethod() itself</p>
  
  <pre><code>[TestMethod]
  public void TestMethod1()
  {
  //generating mocks
  //SampleClass target; //tested class object
  
  Expect.Call(InnerClassMock.TheMethod(
              ref Arg&lt;string&gt;.Ref(Rhino.Mocks.Constraints.Is.Equal(s1), string1).Dummy,
              ref Arg&lt;string&gt;.Ref(Rhino.Mocks.Constraints.Is.Equal(s1), string1).Dummy)).IgnoreArguments();
  
  
          string temp = target.SampleClassMethod();
          Assert.AreEqual("1234", temp);
  }
  </code></pre>