Once again ladies and gentlemen here’s the RhinoMocks template for ReSharper to create your mocked tests in a snap. The last time was exactly the same but for JMocks with Eclipse. This time instead, the requirements are: VisualStudio, ReSharper, NUnit and RhinoMocks as references. To install:
- Download this file (xml export of the template)
- In VisualStudio, ReSharper menu, choose “options”
- Go to “Templates” - “File Templates” and click the import icon
- Select the downloaded XML file
If you just want to have a look:
using NUnit.Framework;
using Rhino.Mocks;
using Rhino.Mocks.Constraints;
namespace $namespace$
{
[TestFixture]
public class $class$
{
private $TargetType$ _a$TargetType$;
private $CollaboratorType$ _a$CollaboratorType$;
private MockRepository _mock;
[SetUp]
public void SetUp()
{
_mock = new MockRepository();
_a$CollaboratorType$ = _mock.CreateMock();
_a$TargetType$ = new $TargetType$(_a$CollaboratorType$);
}
[Test]
public void TEST_METHOD_NAME()
{
using (_mock.Record())
{
}
using (_mock.Playback())
{
}
}
}
}