I'm trying to mock a WCF call. The call to the WCF never gets mocked and it calls the WCF service everytime.
[Isolated]
public void ValidateCustomerPolicyNumberTest(string zipcode, string policyNumber, string policyType, bool mockReturnValue, bool expectedValue)
{
bool actualValue;
var fakeWcfService = Isolate.Fake.Instance<CustomerPolicyDataClient>();
Isolate.WhenCalled(() => fakeWcfService.ValidateCustomerPolicyExists(zipcode, policyNumber)).WillReturn(mockReturnValue);
Isolate.Swap.NextInstance<CustomerPolicyDataClient>().With(fakeWcfService);
actualValue = CustomerPolicy.ValidateCustomerPolicyNumber(zipcode, policyNumber, policyType);
Assert.AreEqual(expectedValue, actualValue);
}
public static class CustomerPolicy
{
public static bool ValidateCustomerPolicyNumber(string zipCode, string policyNumber, string policyType)
{
bool isValid = false;
PolicyTypes policyTypes = new PolicyTypes();
if (policyTypes.ValidatePolicyType(policyNumber, policyType))
{
CustomerPolicyDataClient client = new CustomerPolicyDataClient();
isValid = client.ValidateCustomerPolicyExists(zipCode, policyNumber);
}
return isValid;
}
}
[/code]