Hi,

I've had an issue with the following test case, written against Rhino 3.6:

Method Code:

public class ClassUnderTest{
   public string Arg0{get;set;}
   public string Arg1{get;set;}
   public IValidator Validator {get;set;}

   public bool Validate()
   {
      string proposal = string.Empty;
      try
      {
         if (Validator.IsValid(Arg0, Arg1, ref proposal)) return true;
      }
      catch (ValidationException ex)
      {
         if (!string.IsNullOrEmpty(proposal))
         {
            // I want to test this section of code
         }
      }
      return false;
   }                   }

Test Code:

[TestMethod]public void Test_Validate_ValidatorProposes_ReturnsTrue(){
    string arg0 = "123456789";
    string arg1 = "201208150030551ABC";
    string prop = "123456";

    ClassUnderTest testInstance = new ClassUnderTest();
    testInstance.Arg0 = arg0;
    testInstance.Arg1 = arg1;

    IValidator validatorStub = MockRepository.GenerateStub<IValidator>();
    validatorStub.Stub(x => x.IsValid(Arg<string>.Is.Equal(arg0),
                                      Arg<string>.Is.Equal(arg1),
                                      ref Arg<string>.Ref(Is.Anything(), 
prop).Dummy))
                 .Throw(new ValidationException(string.Empty));
    testInstance.Validator = validatorStub;

    bool actual = testInstance.Validate();

    Assert.IsFalse(actual);}

Actually, the validatorStub will throw the expected exception but not set 
the ref argument.

A User on *StackOverflow*, where I have initially posted this issue, 
<http://stackoverflow.com/questions/16297617/mocking-reference-parameter-with-rhinomocks>hinted
 
me to an issue that is based on the Castle DynamicProxy release that Rhino 
is working with that describes that there is a problem with exactly this 
combination (ref arguments and exception handling). Since that was two 
years ago, I wonder if there's a chance of getting a Rhino build that uses 
a later version of DynamicProxy, one where this is already solved.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rhinomocks?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to