I assume that you're familiar with official documentation, which is quite good in my opinion.
My suggestion is to try to use Rhino, and when you encounter some more specific problem search for solution wither on SO or somewhere else. I don't think that there is a comprehensive cheat sheet for Rhino mocks. I guess you'll have more luck asking "How can I do this and that using Rhino Mocks"
Edit:
Well, you don't need to use Record/Playback when targeting AAA.
There are three steps involved in AAA:
- Arrange, which stands for setting up
the behavior of mocked class, for example
.
IOmicronDll mockWrapper = MockRepository.GenerateMock<IOmicronDll>();
mockWrapper.Expect(wrapper => wrapper.Lock(1, ref errors)).OutRef(string.Empty).Return(true).Repeat.Any();
mockWrapper.Expect(wrapper => wrapper.Exec(1, "sys:cfg?(type)", ref output, ref errors)).OutRef("1,CMC 56,0;", "").Return(true).Repeat.Any();
mockWrapper.Expect(wrapper => wrapper.Exec("1", "sys:cfg?(type)", ref output, ref errors)).OutRef("1,CMC 56,0;", "").Return(true).Repeat.Any();
Microsoft.Practices.Unity.UnityContainer c = new Microsoft.Practices.Unity.UnityContainer();
c.RegisterInstance<IOmicronDll>(mockWrapper);
Act, which stands for executing the tests
public Omicron(int deviceID)
{
try
{
if (g_Omicron == null)
g_Omicron = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<CMEngineWrapper.IOmicronDll>();
m_UniqueIdentifier = Guid.NewGuid();
m_Logger = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<AdvAdmittance.Framework.ILogger>();
m_ID = deviceID;
GetConfiguration();
g_InstancesCount++;
m_PollThread = new Thread(new ThreadStart(DoPoll));
m_PollThread.Start();
}
And Assert, which stands for veryfing
the results
.
Assert.AreEqual("CMC 56", omicron.Type);
mockWrapper.AssertWasCalled(wrapper => wrapper.Release(), options => options.Repeat.AtLeastOnce());
Perhaps the above examples aren't the best, but might get you into right direction.