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

  • Home
  • SEARCH
  • 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 3976464
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:48:28+00:00 2026-05-20T04:48:28+00:00

This is actually my very first question on Stackoverflow. I hope its not the

  • 0

This is actually my very first question on Stackoverflow. I hope its not the last and hopefully I will contribute with some answers myself.

My question is simple. I’m stuck with a NUnit test where I’m testing a inversed HasMany relationship.
Everytime I debug it, the output is “Actual count does not equal expected count…”. I’ve done some extensive research on the net about this issue and some people claim that it’s impossible to do such a unittest.

Here is my example.
Code for EmployeeMapping:

 Id(x => x.ID).GeneratedBy.Identity();
 HasMany(x => x.PositionHistory).KeyColumn("Employee_id").Inverse().Cascade.All();

Here is code for EmployeePositionMapping:

 Id(x => x.ID).GeneratedBy.Identity();
 References(x => x.EmployeeAtPosition).Cascade.All().Nullable();

The Unit test is like this:

 var position2 = new EmployeePosition();
            position2.ExtraBenefit = 353.00;
            position2.Salary = 23300.00;
            position2.Region = region;
            position2.Department = department;
            position2.Year = "2010";
            position2.Comment = "kommentar igen...";
            position2.History = true;
var positionList = new List<EmployeePosition>();

    positionList.Add(position2);

    new PersistenceSpecification<Employee>(Session, new CustomEqualityComparer<Employee, long>())
                     .CheckProperty(p => p.ID, Int64.Parse("1"))
                     .CheckList(p => p.PositionHistory, positionList, (emp, empPosition) => emp.AddEmployeePosition(empPosition))
                     .VerifyTheMappings();

I would like to replace the Nullable() attribute to Not.Nullable() for References EmployeeAtPosition property.

I have a Entity base class that take cares of comparing entities and even Transients.
The AddEmployeePosition() takes care of maintaining the relationship both ways for Employee.PositionHistory and EmployeePosition.EmployeeAtPosition.

When I look at the Nhibernate SQL in output It seems ok. But for some reason it’s not equal the list I’ve prepared (positionList)

Other useful facts: I’m running Nhibernate 3.0 and the matching fluent Nhibernate binaries. Downloded them for three days ago. Using SQLite InMemory for conducting Mapping Tests.

I really appreciate all good new angles that your hints may give me…

/Best Regards BacceSR- from a very snowy Stockholm.

  • 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-20T04:48:29+00:00Added an answer on May 20, 2026 at 4:48 am

    Hmm no Answers. Better answer this one myself :D.
    Well I found the answer after some googling, and there is currently some issues with CheckList method. I used CheckComponent instead and it worked fine. Now “Parent” object is inserted before its “Children” and therefore no error. CheckList tried to do the opposite which didn’t work at all…

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

Sidebar

Related Questions

This is actually a two part question. First,does the HttpContext.Current correspond to the current
Disclaimer: This is not actually a programming question, but I feel the audience on
First off, I know this may be a very stupid question, so don't shoot
First of all, I want to say sorry for this very big question, but
I'm pretty new to the idea of recursion and this is actually my first
I'm not sure what this practice is actually called, so perhaps someone can edit
I've looked at every question so far and none seem to actually answer this
this is my very first post! I'm pretty desperate so I'm going above and
I know this is more heavy question, but I think its interesting too. It
Okay, this is probably very simple but, I have the below checks (not at

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.