in Education by
How would you test this scenario? I've just started looking into NHibernate and having my first bash at TDD. So far I've really enjoyed it and have been using fluent-Nhibernate for my mapping of the classes. However I seem to be hitting a dead end when it comes to using the VerifyTheMappings method on PersistenceSpecification. Essentially I have two classes, Recipient and RecipientList. The RecipientList class has a mapping to the Recipient with a fluent "HasMany" relationship: public class RecipientListMap : ClassMap { public RecipientListMap() { Id(x => x.ID); Map(x => x.ApplicationID); Map(x => x.Name); Map(x => x.IsDeleted); HasMany(x => x.Recipients).WithKeyColumn("RecipientListID").AsList().LazyLoad(); } } However when I use the following code in my test: private IList _recipients = new List() { new Recipient { FirstName = "Joe", LastName = "Bloggs", Email = "[email protected]", IsDeleted = false }, new Recipient { FirstName = "John", LastName = "Doe", Email = "[email protected]", IsDeleted = false }, new Recipient { FirstName = "Jane", LastName = "Smith", Email = "[email protected]", IsDeleted = false } }; [Test] public void Can_Add_RecipientList_To_Database() { new PersistenceSpecification(Session) .CheckProperty(x => x.Name, "My List") .CheckProperty(x => x.Columns, "My columns") .CheckProperty(x => x.IsDeleted, false) .CheckProperty(x => x.ApplicationID, Guid.NewGuid()) .CheckProperty(x => x.Recipients, _recipients) .VerifyTheMappings(); } The following error occurs: failed: System.ApplicationException : Expected 'System.Collections.Generic.List`1[Project.Data.Domains.Recipients.Recipient]' but got 'NHibernate.Collection.Generic.PersistentGenericBag`1[Project.Data.Domains.Recipients.Recipient]' for Property 'Recipients' I can see that the error is because I am passing in a List and the list returned is a PersistentGenericBag, therefore throwing an error. I don't get how you are suppose test this though if you can't just pass in an IList? Any help would be appreciated. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Well stupidely I was using the wrong method on PeristenceSpecification. I should have been using CheckList not CheckProperty. Duh!

Related questions

0 votes
    Ought I to unit test constructors? Say I have a constructor like this: IMapinfoWrapper wrapper; public ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Ought I to unit test constructors? Say I have a constructor like this: IMapinfoWrapper wrapper; public ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Ought I to unit test constructors? Say I have a constructor like this: IMapinfoWrapper wrapper; public ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Ought I to unit test constructors? Say I have a constructor like this: IMapinfoWrapper wrapper; public ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Ought I to unit test constructors? Say I have a constructor like this: IMapinfoWrapper wrapper; public ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Ought I to unit test constructors? Say I have a constructor like this: IMapinfoWrapper wrapper; public ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    The ADT list is more general than common lists and has entries that are objects of the same type. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    The current user defined objects like lists, vectors, etc. is referred to as __________ in the R language. ( ... of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    ______________________ lists all the available database objects.Single choice. Tabs Title bar Navigation pane Groups Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    I've searched stackoverflow for a proper solution on generating a many-to-many relationship, using EF Core, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    I want to make a method that will populate the lst_List list with rows from various tables and fields. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I want to make a method that will populate the lst_List list with rows from various tables and fields. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I have this XML file and am able to read it, but it breaks and returns null once it gets to the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
...