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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:28:41+00:00 2026-05-15T17:28:41+00:00

I’m getting an exception that really makes no sense to me whatsoever. I have

  • 0

I’m getting an exception that really makes no sense to me whatsoever.

I have an Expect call for a method that takes 3 arguments into it: The types are called CallContext, IDal, and List.

NUnit throws me 2 exceptions: One for not expecting a method call that happened where the types are CallContext, System.Object, and List, and one for expecting a call that didn’t happen where the types are the correct ones. The fun thing is that the only way to call the method is with the 3 types mentioned above. There is no method call with type object!

Here is the code:

 private IDal mockDal;
 private CallContext mockContext;
 private IWorkbooksLogic mockWLogic;
 private ICommercialSpaceLogic mockCLogic;
 private CmWorkbook mockWorkbook;
 private IList<Workbook> mockList;
 private MockRepository mock;
private Random random;

 [SetUp]
 public void Setup() {
   mock = new MockRepository();
   random = new Random();
   this.mockDal = mock.StrictMock<IDal>() as IDal;
   this.mockContext = new CallContext();
   this.mockWLogic = mock.StrictMock<IWorkbooksLogic>() as IWorkbooksLogic;
   this.mockCLogic = mock.StrictMock<ICommercialSpaceLogic>() as ICommercialSpaceLogic;
   this.mockWorkbook = new CmWorkbook();
   this.mockList = mock.StrictMock<IList<Workbook>>() as IList<Workbook>;
 }

[Test]
public void ShouldFailWhenCreateWorkbookFails() {

  int randBudget = random.Next(50);
  int randEntity = random.Next(50);
  int randWork = random.Next(50);

  WorkbookDefinitions work = new WorkbookDefinitions {
    WorkbookDefinitionID = randWork
  };

  Budget budget = new Budget {
    BudgetID = randBudget,
    WorkbookDefinitions = new List<WorkbookDefinitions> { work },       
  };

  CommercialProperty property = new CommercialProperty {
    CommercialPropertyID = randEntity,
    CMEntity = new CMEntity { 
      EntityBase = new EntityEntity { EntityCode = "random.Next(50)" }
    }
  };

  CmWorkbook book = new CmWorkbook {
    WorkbookName = String.Format("CM — {0}", property.CMEntity.EntityBase.EntityCode)
  };

  OperationResults results = new OperationResults();
  this.mockList.Add(book);
  using (mock.Record()) {
    Expect.On(this.mockDal).Call(this.mockDal.GetObject<Budget, int>(randBudget)).Return(budget);
    Expect.On(this.mockDal).Call(this.mockDal.GetObject<CommercialProperty, int>(randEntity)).Return(property);
    Expect.On(this.mockWLogic).Call(this.mockWLogic.Create(this.mockContext, this.mockDal, this.mockList)).Return(null);
  }
  using (mock.Playback()) {
    results = CmWorkbookLogic.CreateWorkbook(mockContext, mockDal, mockWLogic, mockCLogic, randBudget, randEntity);
  }
  Assert.IsFalse(results.AllSuccessful);
}

The method being called is: workbooksLogic.Create(context, dal, new List { workbook })
Here is the NUnit error:

ShouldFailWhenCreateWorkbookFails:
Rhino.Mocks.Exceptions.ExpectationViolationException : ICRUDBaseLogic`1.Create(CallContext, System.Object, System.Collections.Generic.List`1[Workbook]); Expected #0, Actual #1.
ICRUDBaseLogic`1.Create(CallContext, IDalProxy8768e63f86da4601993b4791c696ada6, System.Collections.Generic.List`1[Workbook]); Expected #1, Actual #0.

I have no idea what the heck is going on with this. Anyone have any ideas?

  • 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-15T17:28:42+00:00Added an answer on May 15, 2026 at 5:28 pm

    Rhino Mocks uses the overloaded Equals method to compare arguments of the expected invocation and the invocation that actually happened. Some of the objects you are supplying as arguments don’t have Equals overloaded (i.e. List class, not sure about the others), so the only way it would work if the supplied arguments had the same references (so were the same objects) as the ones you used to set up the expectation.

    You have a few options:

    1. Use IgnoreArguments, so that arguments will not be checked at all
    2. Provide your own constraints, so that you can check if the arguments are what you expect them to be, but without using Equals()
    3. Make sure these are exactly the same objects (if possible)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace

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.