Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

http://www.chrisbrandsma.com/2007/09/rhino-mocks-new-syntax.html

The old way:

Code Block
java
java

[Test]
public void MyOldTest() 
{ 
// Record your expectations here 
Expect.Call(myObject.MyProperty).Return(1);

mocks.ReplayAll();

// do your work here 
int i = myObject.MyProperty;

// check you values

mocks.VerifyAll();

Assert.AreEqual(1, i);

}

The new way:

Code Block

[Test]
public void MyNewTest() 
{ 
// Record your expectations here 
using ( mocks.Record() ) 
{ 
Expect.Call(myObject.MyProperty).Return(1); 
}

// do your work here 
int i; 
using ( mocks.Playback() ) 
{ 
i = myObject.MyProperty; 
}

// check you values 
Assert.AreEqual(1, i); 
}