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.assertGenericListMatches
> [ITEM](IEnumerable`1 actualEnumerable, IEnumerable`1
> expectedEnumerable)
>        at
> FluentNHibernate.Testing.PersistenceSpecification`1.ListValue`1.CheckValue
> (Object target)
>        at
> FluentNHibernate.Testing.PersistenceSpecification`1.<>c__DisplayClass2.<VerifyTheMappings>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
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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