Hi!

I wrote a simple test below to illustrate what I think is a very strange
behaviour. To me it looks like a bug but I'm sure there's another
explanation.

I think my test should fail because I expect a property on my mock to be set
ONCE but I call a method on my SUT twice and it in turns sets the property
twice.

If I change to Repeat.Never() I get the error message telling me that my
mock property was called once - not twice. But then Repeat.Twice() should
also fail - but it doesn't. I'm confused.

[Test]
public void test()
{
  TestClass testClass = new TestClass();
  ITestInterface testInterface =
MockRepository.GenerateMock<ITestInterface>();

  testClass.TestInterface = testInterface;

  testInterface.Expect(x => x.ReadWriteProperty =
null).IgnoreArguments().Repeat.Once();

  testClass.SetProperty("1");
  testClass.SetProperty("1");

  testInterface.VerifyAllExpectations();
}


public interface ITestInterface
{
  string ReadWriteProperty { get; set; }
}

public class TestClass
{
  public ITestInterface TestInterface { get; set; }

  public void SetProperty(string s)
  {
    TestInterface.ReadWriteProperty = s;
  }
}


Linus Roslund
Dotway AB, Malmö
-----------------------------
Øredev - 19-21 November 2008 - www.oredev.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to