Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:46:35+00:00 2026-06-05T12:46:35+00:00

When mocking a call to a WCF Service, I get the following error: Method

  • 0

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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:46:37+00:00Added an answer on June 5, 2026 at 12:46 pm

    Remember a mocked object is just that, a mock. There is no implementation at all, so if the mock needs to return a value from a function, it has no way of knowing what to return unless you tell it.

    I assume your GetCustomerFromPhoneNumber() returns a Customer object or id, so you need to tell Rhino what to return:

    I’ve never used Rhino, but hopefully this will point you in the right direction even if the syntax isn’t quite right.

    var test = MockRepository.GenerateMock<ICustomerEntities>(_factory);
    test.Stub(ent => ent.GetCustomerFromPhoneNumber("01234123123")).Return(new Customer());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test where I'm mocking 2 service calls that get called in
I'm trying to use the fluent mocking style of Rhino.Mocks and have the following
Using Moq I am mocking a property, Report TheReport { get; set; } on
I have a unit test (nUnit). Many layers down the call stack a method
I have a typical Silverlight application with a WCF service and I am using
I have a method under test. Within its call stack, it calls a DAO
I have a method like the following: public void ImportDataCommand() { // some data
So assume I am mocking the following class: public class ClassAParams { public int
I am trying to test that the property gets it's value from the return
I had an issue with mocking Apache Http client. The following attempt to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.