Working my way through my huge FNH backlog and I came across this. Jon, if
you happen to read this, I fixed this though I used a slightly different
implementation to your patch - the attribute store actually supports setting
defaults so I used that functionality.

On Wed, Aug 5, 2009 at 4:16 AM, Jon Kruger <[email protected]> wrote:

>
> I have a convention that looks like this:
>
>    public class TableReadOnlyConvention : IClassConvention
>    {
>        public bool Accept(IClassMap target)
>        {
>            return true;
>        }
>
>        public void Apply(IClassMap target)
>        {
>            if (target.EntityType.HasReadOnlyAttribute())
>                target.ReadOnly();
>        }
>    }
>
> ... and I have tests for my conventions that look like this:
>
>        [Test]
>        public void
> Should_not_set_read_only_flag_on_classes_that_are_not_read_only()
>        {
>            _model.FindMapping<SampleEntityClass>().GetClassMapping
> ().Mutable.ShouldBeTrue();
>        }
>
>        [Test]
>        public void Should_set_read_only_flag_on_read_only_classes()
>        {
>            _model.FindMapping<SampleReadOnlyEntityClass>
> ().GetClassMapping().Mutable.ShouldBeFalse();
>        }
>
> The first test fails because if you never set the Mutable property (by
> calling ReadOnly() in your class mapping or convention), the attribute
> is not set, and in that case ClassMapping.Mutable returns the default
> value for a bool, which is false.  But this is technically wrong
> because the class is mutable (even though it's not explicitly set in
> the mappings) because classes are mutable by default.
>
> I created a patch for this (sorry, I haven't learned Git yet, so it's
> an SVN patch), which you can get here:
> http://jonkruger.com/fluent-nhibernate/04_Mutable_defaults_to_true.patch
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to