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 6150681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:39:06+00:00 2026-05-23T19:39:06+00:00

Rhino.Mocks.Exceptions.ExpectationViolationException was unhandled by user code Message=Service.GetCommunityLightPagered(null, 1, null, null, Data.PagingInfo); Expected #0, Actual

  • 0
 Rhino.Mocks.Exceptions.ExpectationViolationException was unhandled by user code
 Message=Service.GetCommunityLightPagered(null, 1, null, null, Data.PagingInfo); 
 Expected #0, Actual #1.
 Service.GetCommunityLightPagered(null, 1, null, null, Data.PagingInfo); 
 Expected #1, Actual #0.
 Source=Rhino.Mocks

The 2 classes PagingInfo are 2 instances but have the same values and are verified before with asserts.

Here is the unit test code

        //Arrange
        GetController("user1");

        //Act
        using (MockRepository.Record())
        {
            Expect.Call(
                ServiceClient.GetMock<Service>().GetUserPermissionSet(
                    "user1", false, false, false)).Return(
                        Db.User.Permissions.Where(p => p.Name == "CreateCommunity").ToArray());
        }
        using (MockRepository.Playback())
        {
            ActionResult result = Controller.ExecuteAction<int?, int?, string, string, string, string, string, string>(ServiceClient, Controller.SearchCommunities, null, null,null, null, null, CommunityTypeEnum.HighSchool, null,null);
            //Assert
            Assert.AreEqual(typeof(PartialViewResult), result.GetType());
        }
  • 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-05-23T19:39:07+00:00Added an answer on May 23, 2026 at 7:39 pm

    problem solved :

    Expect.Call(ServiceClient.GetMock<IUserService>().GetCommunityLightPagered(null, 1, null,null, new PagingInfo
                    {
                        Page = 1,
                        Rows = 10,
                        SortColumn = "Id",
                        SortOrder = "desc"
                    })
                    ).IgnoreArguments().Return(TestHelper.CommunityInfoLightDTO());
    

    Now all calls to this ,will be considered valid.

    Edit 1: Why you should use IgnoreArguments()? Because sometimes you have big objects that need to be mocked and maybe you only want to test a small part of it.
    I usually use it when i have objects as parameters.
    Another way to avoid using it is by using same hashcode to both objects, the one used for record and the one used as param in playback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When executing the second line of this code Rhino Mocks throws an InvalidOperationException with
I have following code that I'm trying to test using NUnit and Rhino mocks.
I am using Rhino Mocks. I have a data repository, a small part of
The Rhino Mocks download comes with a Rhino.Mocks.xml file that apparently adds Intellisense for
What is Rhino Mocks Repeat ? Repeat.Any(); Repeat.Once(); What does it mean and how
Is it possible in Rhino.Mocks to verify whether a specified constructor was called? Consider
I'm playing around with Rhino Mocks and am trying to set some dummy results
So I'm new to rhino mocks and I'm trying to get it going in
How can I Mock Indexed Property with Rhino Mocks ?
The following test case fails in rhino mocks: [TestFixture] public class EnumeratorTest { [Test]

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.