Is this to say that the mapping for the self-referencing Category
class described in the NHibernate in Action book cannot be duplicated
with Fluent NHibernate?  I have a FNH mapping extremely similar to the
one listed by 'aragorn', but I am also getting:
System.ApplicationException: Actual count does not equal expected
count.  There are no solutions for this issue?

On Mar 18, 11:58 pm, Paul Batum <paul.ba...@gmail.com> wrote:
> Good catch Brendan. I need to pay more attention.
>
>
>
> On Thu, Mar 19, 2009 at 2:34 PM, Brendan Erwin <brendanjer...@gmail.com> 
> wrote:
> > He's not testing the actual object created in his example. He's testing the
> > Catalog entity which "HasMany" Business entities.
> > Here is an example from my project that works:
> >         [Test]
> >         public void PayerMapping()
> >         {
> >             var states = new List<State> { new State { Abbreviation = "CA",
> > Name = "California" } };
> >             new PersistenceSpecification<PayerModel>(session)
> >                 .CheckProperty(x => x.Active, true)
> >                 .CheckProperty(x => x.Name, "asdfgh")
> >                 .CheckList(x => x.States, states)
> >                 .VerifyTheMappings();
> >         }
> > The problem is that the Catalog.Businesses association is Inverse but there
> > is no way to set the Business.Catalog value to the instance that the
> > PersistenceSpecification creates. In my working example, the States
> > association is not inverse.
> > The short answer is that you can't test Inverse collection associations with
> > PersistenceSpecification.
> > What would the api even look like that would allow you to set that? Maybe
> > something like : .CheckInverseList(x=>x.Assoc, i=>i.Parent, ListOfItems)
> > where i is the list item type. Then the PersistenceSpecification could set
> > the specified property to the instance of the entity under test it creates.
>
> > On Mar 18, 2009, at 5:38 PM, Paul Batum wrote:
>
> > That is not how it works. The PersistenceSpecification does not test
> > against an object instance that you have created. Here is an example
> > test from the the ConnectedTester:
>
> >        [Test]
> >        public void MappingTest1()
> >        {
> >            new PersistenceSpecification<Record>(_source)
> >                .CheckProperty(r => r.Age, 22)
> >                .CheckProperty(r => r.Name, "somebody")
> >                .CheckProperty(r => r.Location, "somewhere")
> >                .VerifyTheMappings();
> >        }
>
> > On Wed, Mar 18, 2009 at 11:57 PM, aragorn185 <lionel.mo...@valtech.fr>
> > wrote:
>
> > Hello,
>
> > i would like to use PersistenceSpecification in order to test my
>
> > mapping.
>
> > My mapping is:
>
> > public CatalogMap()
>
> >        {
>
> >            Id(x => x.Id, "id");
>
> >            Map(x => x.Name, "name");
>
> >            HasMany(x => x.Businesses)
>
> >                .Inverse()
>
> >                .KeyColumnNames.Add("catalog_id")
>
> >                .Cascade.All();
>
> >        }
>
> > public BusinessMap()
>
> >        {
>
> >            Id(x => x.Id, "id");
>
> >            Map(x => x.Client, "client");
>
> >            Map(x => x.Contact, "contact");
>
> >            Map(x => x.Cost, "cost");
>
> >            Map(x => x.DailyCost, "daily_cost");
>
> >            Map(x => x.Department, "department");
>
> >            Map(x => x.EndDate, "end_date");
>
> >            Map(x => x.Otp, "otp");
>
> >            Map(x => x.StartDate, "start_date");
>
> >            HasMany(x => x.WorkPackages)
>
> >                .Inverse()
>
> >                .KeyColumnNames.Add("business_id")
>
> >                .Cascade.All();
>
> >            HasMany(x => x.Requests)
>
> >                .Inverse()
>
> >                .KeyColumnNames.Add("business_id")
>
> >                .Cascade.All();
>
> >            References(x => x.Catalog, "catalog_id").FetchType.Join();
>
> >        }
>
> > My testing part is:
>
> > [Test]
>
> >        public void VerifyCatalogSave()
>
> >        {
>
> >            IList<Business> businesses = new List<Business>();
>
> >            Business business1 = new Business();
>
> >            business1.Client = "Client";
>
> >            business1.Contact = "Contact";
>
> >            business1.Cost = 100;
>
> >            business1.DailyCost = 300;
>
> >            business1.Department = "Department";
>
> >            business1.EndDate = DateTime.Now;
>
> >            business1.Otp = "Otp";
>
> >            business1.StartDate = DateTime.Now;
>
> >            businesses.Add(business1);
>
> >            new PersistenceSpecification<Catalog>
>
> > (NHibernateHttpModule.CurrentSession)
>
> >            .CheckProperty(x => x.Name, "Catalog 1")
>
> >            .CheckList(x => x.Businesses, businesses)
>
> >            .VerifyTheMappings();
>
> >        }
>
> > but i have the following error:
>
> > System.ApplicationException : Actual count does not equal expected
>
> > count
>
> >        at
>
> > FluentNHibernate.Testing.PersistenceSpecification`1.ListValue`1.assertGener­icListMatches
>
> > [ITEM](IEnumerable`1 actualEnumerable, IEnumerable`1
>
> > expectedEnumerable)
>
> >        at
>
> > FluentNHibernate.Testing.PersistenceSpecification`1.ListValue`1.CheckValue
>
> > (Object target)
>
> >        at
>
> > FluentNHibernate.Testing.PersistenceSpecification`1.<>c__DisplayClass2.<Ver­ifyTheMappings>b__1
>
> > (PropertyValue p)
>
> >        at System.Collections.Generic.List`1.ForEach(Action`1 action)
>
> >        at
>
> > FluentNHibernate.Testing.PersistenceSpecification`1.VerifyTheMappings
>
> > ()
>
> >        C:\Svn\T-Systems\T-Rack\trunk\server\TRackTest\TrackingServiceTest.cs
>
> > (52,0): at TRackTest.TrackingServiceTest.VerifyCatalogSave()
>
> > Thnaks in advance for any help- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to