Scenario: Validate that my class issues a RestRequest with the provided IRestclient where certain Parameters are set on the request.
public class MyClass {
private readonly IRestClient _client;
public MyClass(IRestClient client) {
_client = client;
}
void DoIt() {
var req = new RestRequest { Method = WebMethod.Get, Path = "/DoIt" };
req.AddParameter("key1", "value1");
req.AddParameter("key2", "value2");
var resp = _client.Request(req);
}
}
[TestFixture]
public class MyClassTests {
[Test]
public void VerifyDoIt() {
var client = MockRepository.GenerateStrictMock<IRestClient>();
var resp = new RestResponse { StatusCode = HttpStatusCode.OK };
client.Expect(x => x.Request(null)).IgnoreArguments().WhenCalled(inv => {
var req = inv.Arguments[0] as RestRequest;
//NO WAY TO VALIDATE THAT PARAMETERS HAS BEEN SET!
inv.ReturnValue = resp;
});
}
}
Is Hammock simply not testable in this fashion or am I missing something crucial?
Edit: this is not a question about on how to access/validate method parameters with Rhino.Mocks, but rather how/if Hammock supports testing/validating that request parameters are set in unit-test scenarios.