Hey Gabriel, This completely fell off my radar just before I went away, sorry about that. I've committed a fix that at the very least makes your test pass! Hopefully it should let you carry on.
On Tue, Aug 19, 2008 at 8:08 AM, James Gregory <[EMAIL PROTECTED]>wrote: > Thanks Gabriel, I'll take a look at this as soon as I can. > > > On Mon, Aug 18, 2008 at 11:16 PM, Gabriel Schenker <[EMAIL PROTECTED]>wrote: > >> sure! >> This is the domain >> >> public class Blog : Entity >> { >> public Blog() >> { >> Posts = new HashedSet<Post>(); >> } >> >> public virtual string Name { get; set; } >> public virtual Person Author { get; set; } >> public virtual ISet<Post> Posts { get; private set; } >> } >> >> public class Post : Entity >> { >> public Post() >> { >> Comments = new HashedSet<Comment>(); >> } >> >> public virtual string Title { get; set; } >> public virtual string Body { get; set; } >> public virtual DateTime PublicationDate { get; set; } >> public virtual ISet<Comment> Comments { get; private set; } >> } >> >> public class Comment >> { >> private Comment() >> { } >> >> public Comment(string text, DateTime creationDate, string >> authorEmail) >> { >> Text = text; >> CreationDate = creationDate; >> AuthorEmail = authorEmail; >> } >> >> public virtual string Text { get; private set; } >> public virtual DateTime CreationDate { get; set; } >> public virtual string AuthorEmail { get; private set; } >> } >> >> public class Person : Entity >> { >> public virtual string FirstName { get; set; } >> public virtual string LastName { get; set; } >> } >> >> //====================================================================== >> >> this is the mapping: >> >> public class PersonMap : ClassMap<Person> >> { >> public PersonMap() >> { >> Id(x => x.Id); >> Map(x => x.FirstName); >> Map(x => x.LastName); >> } >> } >> >> public class BlogMap : ClassMap<Blog> >> { >> public BlogMap() >> { >> Id(x => x.Id); >> Map(x => x.Name); >> References(x => x.Author); >> HasMany<Post>(x => x.Posts).AsSet(); >> } >> } >> >> public class PostMap : ClassMap<Post> >> { >> public PostMap() >> { >> Id(x => x.Id); >> Map(x => x.Title); >> Map(x => x.Body); >> Map(x => x.PublicationDate); >> HasMany<Comment>(x => x.Comments) >> .Component(c => >> { >> c.Map(x => x.Text); >> c.Map(x => x.CreationDate); >> c.Map(x => x.AuthorEmail); >> }).AsSet(); >> >> } >> } >> >> //====================================================================== >> >> and finally a failing test (with a failing CheckComponentList method) >> >> [TestFixture] >> public class Post_Fixture : FixtureBase >> { >> [Test] >> public void Can_map_post_revisited() >> { >> IList<Comment> comments = new[] >> { >> new Comment("So so", >> DateTime.Today, "[EMAIL PROTECTED]"), >> new Comment("La la", >> DateTime.Today, "[EMAIL PROTECTED]"), >> }; >> new PersistenceSpecification<Post>(Session) >> .CheckProperty(x=>x.Title, "Some title") >> .CheckProperty(x=>x.Body, "Some body") >> .CheckProperty(x=>x.PublicationDate, DateTime.Today) >> .CheckComponentList(x=>x.Comments, comments) >> .VerifyTheMappings(); >> } >> } >> >> //============================================================== >> >> here are the test fixture base class and my persistence model >> >> public class FixtureBase >> { >> protected SessionSource SessionSource { get; set; } >> protected ISession Session { get; private set; } >> >> [SetUp] >> public void SetupContext() >> { >> Before_each_test(); >> } >> >> [TearDown] >> public void TearDownContext() >> { >> After_each_test(); >> } >> >> protected virtual void Before_each_test() >> { >> var persistenceModel = new MyPersistenceModel(); >> >> SessionSource = new SessionSource(persistenceModel); >> Session = SessionSource.CreateSession(); >> SessionSource.BuildSchema(Session); >> CreateInitialData(Session); >> Session.Flush(); >> Session.Clear(); >> } >> >> protected virtual void After_each_test() >> { >> Session.Close(); >> Session.Dispose(); >> } >> >> protected virtual void CreateInitialData(ISession session) >> { >> } >> } >> >> public class MyPersistenceModel : PersistenceModel >> { >> public MyPersistenceModel() >> { >> addMappingsFromAssembly(typeof(BlogMap).Assembly); >> } >> } >> >> //=============================================================== >> >> On Tue, Aug 19, 2008 at 12:08 AM, James Gregory <[EMAIL PROTECTED]>wrote: >> >>> Hmm, this is quite weird. Any chance you could forward me a test or >>> something to replicate this? >>> >>> >>> On Mon, Aug 18, 2008 at 11:06 PM, Gabriel Schenker <[EMAIL PROTECTED] >>> > wrote: >>> >>>> by the way: the same error with the CheckComponentList method if testing >>>> a collection of value objects! >>>> >>>> >>>> On Mon, Aug 18, 2008 at 11:39 PM, Gabriel Schenker < >>>> [EMAIL PROTECTED]> wrote: >>>> >>>>> unfortunately this does still not work. >>>>> I have a parent object eg. Order which has a property OrderLines of >>>>> type ISet<OrderLine>. If I try to test the mapping with the newest (I just >>>>> downloaded it) PersistenceSpecification class, i.e >>>>> >>>>> new PersistenceSpecification<Order>(session) >>>>> .CheckProperty(...) >>>>> ... >>>>> .CheckList(x => x.OrderLines, sampleOrderLines) >>>>> .VerifyTheMappings(); >>>>> >>>>> where sampleOrderLines are of type List<OrderLine> >>>>> it still raises an error >>>>> >>>>> System.ArgumentException: Object of type >>>>> 'System.Collections.Generic.List`1[FluentMapping.Domain.Scenario3.OrderLine]' >>>>> >>>>> >>>>> cannot be converted to type >>>>> 'Iesi.Collections.Generic.ISet`1[FluentMapping.Domain.Scenario3.OrderLine]'. >>>>> >>>>> which makes sense to me... BUT I cannot pass an ISet<OrderLine> type >>>>> collection as second parameter to the CheckList method >>>>> Should the CheckList method not have its second parameter of e.g. type >>>>> IEnumerable<T>? >>>>> >>>>> >>>>> >>>>> On Sat, Aug 16, 2008 at 11:07 AM, Gabriel Schenker < >>>>> [EMAIL PROTECTED]> wrote: >>>>> >>>>>> Thanks, will test it shortly... >>>>>> >>>>>> On Sat, Aug 16, 2008 at 1:21 AM, James Gregory <jagregory.com@ >>>>>> gmail.com> wrote: >>>>>> >>>>>>> Alright, I've applied a fix that should help with this. >>>>>>> It basically comes down to that you're passing a new[] {} in which is >>>>>>> being assigned to the property, which is of ISet. I've updated the >>>>>>> method to >>>>>>> now instantiate the property and copy the values, rather than just a >>>>>>> straight assign. >>>>>>> >>>>>>> On Fri, Aug 15, 2008 at 11:17 PM, James Gregory <jagregory.com@ >>>>>>> gmail.com> wrote: >>>>>>> >>>>>>>> I've had a dig in the code and there's a hard cast to IList in the >>>>>>>> PersistenceSpecification, I bet that's what's causing your problem. >>>>>>>> I'm just working on replicating your issue, then I'll try to fix it. >>>>>>>> >>>>>>>> >>>>>>>> On Fri, Aug 15, 2008 at 3:05 PM, Gabriel Schenker < >>>>>>>> [EMAIL PROTECTED]> wrote: >>>>>>>> >>>>>>>>> unfortunately I was a little bit TOO optimistic in my blog post... >>>>>>>>> I forgot to add the VerifyTheMappings method when leveraging the >>>>>>>>> PersistenceSpecification class >>>>>>>>> Now having added it the follwoing test fails >>>>>>>>> >>>>>>>>> [Test] >>>>>>>>> public void Can_add_post_to_blog_revisited() >>>>>>>>> { >>>>>>>>> var posts = new[] >>>>>>>>> { >>>>>>>>> new Post { >>>>>>>>> Title = "First Post", >>>>>>>>> Body = "Just a test", >>>>>>>>> PublicationDate = >>>>>>>>> DateTime.Today >>>>>>>>> }, >>>>>>>>> new Post { >>>>>>>>> Title = "Second Post", >>>>>>>>> Body = "Just another >>>>>>>>> test", >>>>>>>>> PublicationDate = >>>>>>>>> DateTime.Today.AddDays(-1) >>>>>>>>> }, >>>>>>>>> }; >>>>>>>>> >>>>>>>>> new PersistenceSpecification<Blog>(Session) >>>>>>>>> .CheckProperty(x => x.Name, "Gabriel's Blog") >>>>>>>>> .CheckProperty(x => x.Author, author) >>>>>>>>> .CheckList(x => x.Posts, posts) >>>>>>>>> .VerifyTheMappings(); >>>>>>>>> } >>>>>>>>> >>>>>>>>> with an error message of >>>>>>>>> >>>>>>>>> >>>>>>>>> System.ArgumentException: Object of type >>>>>>>>> 'FluentMapping.Domain.Scenario3.Post[]' cannot be converted to type >>>>>>>>> 'Iesi.Collections.Generic.ISet`1[FluentMapping.Domain.Scenario3.Post]'. >>>>>>>>> >>>>>>>>> any clues? >>>>>>>>> >>>>>>>>> >>>>>>>>> On Fri, Aug 15, 2008 at 3:40 PM, Gabriel Schenker < >>>>>>>>> [EMAIL PROTECTED]> wrote: >>>>>>>>> >>>>>>>>>> >>>>>>>>>> Hey guys, I have just published a new post at the NHibernate FAQ >>>>>>>>>> blog >>>>>>>>>> regarding the mapping framework. It might be of interest to you to >>>>>>>>>> find out what frictions are still around when applying the >>>>>>>>>> framework >>>>>>>>>> to a "real life" scenario. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/08/15/a-fluent-interface-to-nhibernate---part-3---mapping.aspx >>>>>>>>>> >>>>>>>>>> I hope I will have to update the posts soon (since you will >>>>>>>>>> implement >>>>>>>>>> that many improvements...) >>>>>>>>>> Keep on going >>>>>>>>>> >>>>>>>>>> :-)) >>>>>>>>>> Gabriel >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---