Skip to content

Commit 81bdbc0

Browse files
committed
think I found a bug, need to refactor - Member property never set in ComponentMapping
1 parent 4c7832c commit 81bdbc0

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

src/FluentNHibernate.1.2.dotCover

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Configuration>
2+
<SnapshotDialog>
3+
<InitialDirectory>D:\coding\fluent-nhibernate\src</InitialDirectory>
4+
</SnapshotDialog>
5+
<CoverageFilters>
6+
<IncludeFilters>
7+
<Filter ModuleMask="*" ClassMask="*" FunctionMask="*" />
8+
</IncludeFilters>
9+
<ExcludeFilters />
10+
</CoverageFilters>
11+
</Configuration>

src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@
414414
<Compile Include="Utils\TypeReferenceEqualityTests.cs" />
415415
<Compile Include="Properties\AssemblyInfo.cs" />
416416
<Compile Include="Visitors\ComponentColumnPrefixVisitorSpecs.cs" />
417+
<Compile Include="Visitors\ComponentColumnPrefixVisitorSpecs2.cs" />
417418
<Compile Include="Visitors\ComponentReferenceResolutionVisitorSpecs.cs" />
418419
<Compile Include="Xml\MappingXmlTestHelper.cs" />
419420
</ItemGroup>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using FluentNHibernate.Mapping;
6+
using FluentNHibernate.MappingModel;
7+
using FluentNHibernate.MappingModel.ClassBased;
8+
using FluentNHibernate.Utils;
9+
using NUnit.Framework;
10+
11+
namespace FluentNHibernate.Testing.Visitors
12+
{
13+
[TestFixture]
14+
public class ComponentColumnPrefixVisitorSpecs2: ComponentColumnPrefixVisitorSpec
15+
{
16+
PersistenceModel model;
17+
IEnumerable<HibernateMapping> mappings;
18+
ClassMapping targetMapping;
19+
const string columnPrefix = "{property}";
20+
21+
public override void establish_context()
22+
{
23+
model = new PersistenceModel();
24+
25+
var componentMap = new ComponentMap<FieldComponent>();
26+
componentMap.Map(x => x.X);
27+
componentMap.Map(x => x.Y);
28+
29+
model.Add(componentMap);
30+
31+
var classMapping = new ClassMap<Root>();
32+
classMapping.Id(r => r.Id);
33+
classMapping.Component(Reveal.Member<Root, FieldComponent>("component"), cpt => cpt.Access.Field().ColumnPrefix(columnPrefix));
34+
model.Add(classMapping);
35+
}
36+
37+
public override void because()
38+
{
39+
mappings = model.BuildMappings().ToList();
40+
targetMapping = mappings.SelectMany(x => x.Classes).FirstOrDefault(x => x.Type == typeof(Root));
41+
}
42+
43+
[Test]
44+
public void should_prefix_field_columns()
45+
{
46+
var t = targetMapping.Components.Single();
47+
Console.Write("fdkgndfgkndfgkjn");
48+
//.Properties.SelectMany(x => x.Columns)
49+
//.Each(c => c.Name.ShouldStartWith("component"));
50+
}
51+
}
52+
53+
class Root
54+
{
55+
FieldComponent component;
56+
public int Id { get; set; }
57+
}
58+
59+
class FieldComponent
60+
{
61+
public string X { get; set; }
62+
public int? Y { get; set; }
63+
}
64+
}

src/FluentNHibernate/Mapping/ComponentPart.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ private ComponentPart(Type entity, Member property, AttributeStore attributes)
2222
this.entity = entity;
2323
}
2424

25+
/// <summary>
26+
/// Sets the prefix for every column defined within the component. To refer to the name of a member that exposes
27+
/// the component use {property}
28+
/// </summary>
29+
/// <param name="prefix"></param>
2530
public void ColumnPrefix(string prefix)
2631
{
2732
columnPrefix = prefix;

0 commit comments

Comments
 (0)