When mocking a call to a WCF Service, I get the following error:
Method 'ICustomerEntities.GetCustomerFromPhoneNumber("01234123123");' requires a return value or an exception to throw.
I've googled this and searched on here - all I can find is I need to re-order various calls etc, but that doesn't seem to make sense in my situation? Perhaps someone could point out to me that it actually does?
My test setup looks like this
_entities = MockRepository.GenerateStrictMock<ICustomerEntities>();
And the test method fails on the third line, setting result2
_entities.Expect(ip => ip.GetCustomerFromPhoneNumber("01234123123"));
var test = MockRepository.GenerateMock<ICustomerEntities>(_factory);
var result2 = _entities.GetCustomerFromPhoneNumber("01234123123");
var result = test.GetAllCustomersWithAGivenPhoneNumber("01234123123");
Assert.AreEqual(result,result2);
The original call is attempting to mock this (its in a method called GetAllCustomersWithAGivenPhoneNumber
):
using (var entities = _factory.CreateEntities())
{
var customer = entities.GetCustomerFromPhoneNumber(telephoneNumber);
}