Skip to content
Browse files

think I found a bug, need to refactor - Member property never set in …

…ComponentMapping
  • Loading branch information...
1 parent 4c7832c commit 81bdbc00bb823c298dfb83ef0f732b948051f558 @chester89 chester89 committed Aug 15, 2012
View
11 src/FluentNHibernate.1.2.dotCover
@@ -0,0 +1,11 @@
+<Configuration>
+ <SnapshotDialog>
+ <InitialDirectory>D:\coding\fluent-nhibernate\src</InitialDirectory>
+ </SnapshotDialog>
+ <CoverageFilters>
+ <IncludeFilters>
+ <Filter ModuleMask="*" ClassMask="*" FunctionMask="*" />
+ </IncludeFilters>
+ <ExcludeFilters />
+ </CoverageFilters>
+</Configuration>
View
1 src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj
@@ -414,6 +414,7 @@
<Compile Include="Utils\TypeReferenceEqualityTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Visitors\ComponentColumnPrefixVisitorSpecs.cs" />
+ <Compile Include="Visitors\ComponentColumnPrefixVisitorSpecs2.cs" />
<Compile Include="Visitors\ComponentReferenceResolutionVisitorSpecs.cs" />
<Compile Include="Xml\MappingXmlTestHelper.cs" />
</ItemGroup>
View
64 src/FluentNHibernate.Testing/Visitors/ComponentColumnPrefixVisitorSpecs2.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FluentNHibernate.Mapping;
+using FluentNHibernate.MappingModel;
+using FluentNHibernate.MappingModel.ClassBased;
+using FluentNHibernate.Utils;
+using NUnit.Framework;
+
+namespace FluentNHibernate.Testing.Visitors
+{
+ [TestFixture]
+ public class ComponentColumnPrefixVisitorSpecs2: ComponentColumnPrefixVisitorSpec
+ {
+ PersistenceModel model;
+ IEnumerable<HibernateMapping> mappings;
+ ClassMapping targetMapping;
+ const string columnPrefix = "{property}";
+
+ public override void establish_context()
+ {
+ model = new PersistenceModel();
+
+ var componentMap = new ComponentMap<FieldComponent>();
+ componentMap.Map(x => x.X);
+ componentMap.Map(x => x.Y);
+
+ model.Add(componentMap);
+
+ var classMapping = new ClassMap<Root>();
+ classMapping.Id(r => r.Id);
+ classMapping.Component(Reveal.Member<Root, FieldComponent>("component"), cpt => cpt.Access.Field().ColumnPrefix(columnPrefix));
+ model.Add(classMapping);
+ }
+
+ public override void because()
+ {
+ mappings = model.BuildMappings().ToList();
+ targetMapping = mappings.SelectMany(x => x.Classes).FirstOrDefault(x => x.Type == typeof(Root));
+ }
+
+ [Test]
+ public void should_prefix_field_columns()
+ {
+ var t = targetMapping.Components.Single();
+ Console.Write("fdkgndfgkndfgkjn");
+ //.Properties.SelectMany(x => x.Columns)
+ //.Each(c => c.Name.ShouldStartWith("component"));
+ }
+ }
+
+ class Root
+ {
+ FieldComponent component;
+ public int Id { get; set; }
+ }
+
+ class FieldComponent
+ {
+ public string X { get; set; }
+ public int? Y { get; set; }
+ }
+}
View
5 src/FluentNHibernate/Mapping/ComponentPart.cs
@@ -22,6 +22,11 @@ private ComponentPart(Type entity, Member property, AttributeStore attributes)
this.entity = entity;
}
+ /// <summary>
+ /// Sets the prefix for every column defined within the component. To refer to the name of a member that exposes
+ /// the component use {property}
+ /// </summary>
+ /// <param name="prefix"></param>
public void ColumnPrefix(string prefix)
{
columnPrefix = prefix;

0 comments on commit 81bdbc0

Please sign in to comment.
Something went wrong with that request. Please try again.