Skip to content

Commit 3abe8d6

Browse files
committed
merge changes from master
2 parents 61e5ac7 + c5583eb commit 3abe8d6

File tree

15 files changed

+442
-21
lines changed

15 files changed

+442
-21
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ src/packages
2626
*.ncrunchproject
2727
*.swp
2828
TestResult.xml
29+
<<<<<<< HEAD
2930
src/packages/
3031
TestResult.xml
3132
build/
33+
=======
34+
*.ncrunchsolution
35+
*.ncrunchproject
36+
packages/
37+
>>>>>>> master

src/Examples.FirstAutomappedProject/Examples.FirstAutomappedProject.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@
7171
<ErrorReport>prompt</ErrorReport>
7272
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
7373
</PropertyGroup>
74-
<ItemGroup>
74+
<ItemGroup>
7575
<Reference Include="NHibernate">
7676
<HintPath>..\packages\NHibernate.3.3.1.4000\lib\Net35\NHibernate.dll</HintPath>
77-
</Reference>
77+
</Reference>
7878
<Reference Include="Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
7979
<HintPath>..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
8080
</Reference>
@@ -122,7 +122,9 @@
122122
</BootstrapperPackage>
123123
</ItemGroup>
124124
<ItemGroup>
125-
<None Include="packages.config" />
125+
<None Include="packages.config">
126+
<SubType>Designer</SubType>
127+
</None>
126128
</ItemGroup>
127129
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
128130
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

src/FluentNHibernate.Specs/PersistenceModel/SubclassSpecs.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public class when_subclass_map_has_a_has_many_to_another_entity
3939
model.Add(new SpecialProductMap());
4040
model.Add(new OptionMap());
4141

42-
cfg = new Configuration();
43-
SQLiteConfiguration.Standard.InMemory()
44-
.ConfigureProperties(cfg);
45-
model.Configure(cfg);
42+
//cfg = new Configuration();
43+
//SQLiteConfiguration.Standard.InMemory()
44+
// .ConfigureProperties(cfg);
45+
//model.Configure(cfg);
4646

47-
new SchemaExport(cfg).Create(true, false);
47+
//new SchemaExport(cfg).Create(true, false);
4848
};
4949

5050
Because of = () =>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using FluentNHibernate.Automapping.TestFixtures.SuperTypes;
6+
using FluentNHibernate.Testing.Automapping;
7+
using NUnit.Framework;
8+
9+
namespace FluentNHibernate.Testing.AutoMapping
10+
{
11+
[TestFixture]
12+
public class InheritanceTests: BaseAutoMapFixture
13+
{
14+
[Test]
15+
public void AutoMapSimpleProperties()
16+
{
17+
Model<ThirdLevel>();
18+
19+
Test<ThirdLevel>(mapping =>
20+
{
21+
mapping.Element("//property[@name='Rate']/column").HasAttribute("name", "Rate");
22+
mapping.Element("//property[@name='SecondRate']/column").HasAttribute("name", "SecondRate");
23+
});
24+
}
25+
26+
[Test]
27+
public void AutoMapInheritedIdProperty()
28+
{
29+
Model<SecondLevel>();
30+
31+
Test<SecondLevel>(mapping => mapping.Element("//id").HasAttribute("name", "Id"));
32+
}
33+
34+
[Test]
35+
public void AutoMapManyToOne()
36+
{
37+
Model<FourthLevel>();
38+
39+
Test<FourthLevel>(mapping => mapping.Element("//many-to-one").HasAttribute("name", "One").
40+
Element("//many-to-one/column").HasAttribute("name", "One_id"));
41+
}
42+
43+
[Test]
44+
public void AutoMapManyToMany()
45+
{
46+
Model<FourthLevel>();
47+
48+
Test<FourthLevel>(mapping =>
49+
{
50+
mapping.Element("//many-to-many/column").HasAttribute("name", "ManyToMany_id");
51+
});
52+
}
53+
54+
[Test]
55+
public void AutoMapEnum()
56+
{
57+
Model<FourthLevel>(model => model.Override<FourthLevel>(map => map.Map(x => x.publisherType)));
58+
59+
Test<FourthLevel > (mapping => mapping.Element("//property[@name='publisherType']").Exists());
60+
}
61+
62+
[Test]
63+
public void AutoMapVersion()
64+
{
65+
Model<ThirdLevel>();
66+
67+
Test<ThirdLevel>(mapping =>
68+
{
69+
mapping.Element("//version").HasAttribute("name", "Version");
70+
mapping.Element("//version/column").HasAttribute("name", "Version");
71+
});
72+
}
73+
}
74+
}

src/FluentNHibernate.Testing/AutoMapping/TestFixtures.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,5 +470,60 @@ public class ExampleParentClass : SuperType
470470
public virtual IList<ExampleClass> Examples {get; set;}
471471
}
472472

473+
public abstract class Base1
474+
{
475+
public virtual int Id { get; protected set; }
476+
public abstract void Foo(int x);
477+
}
478+
479+
public class Derived1 : Base1
480+
{
481+
public virtual Decimal Rate { get; set; }
482+
public override void Foo(int x)
483+
{
484+
}
485+
486+
public string GetSomething()
487+
{
488+
return Environment.NewLine;
489+
}
490+
}
491+
492+
public class SecondLevel : Derived1
493+
{
494+
public virtual Double SecondRate { get; set; }
495+
}
496+
497+
public class ThirdLevel : SecondLevel
498+
{
499+
public virtual Boolean Flag { get; set; }
500+
public virtual TimeSpan Version { get; set; }
501+
}
502+
503+
public class FourthLevel: ThirdLevel
504+
{
505+
public PublisherType publisherType { get; set; }
506+
public ToOne One { get; set; }
507+
public IList<ManyToMany> Many { get; set; }
508+
}
509+
510+
public class ToOne
511+
{
512+
public virtual int Id { get; protected set; }
513+
public virtual string Name { get; set; }
514+
}
473515

516+
public class ManyToMany
517+
{
518+
public virtual int Id { get; protected set; }
519+
public virtual Decimal Value { get; set; }
520+
public IList<FourthLevel> Levels { get; set; }
521+
}
522+
523+
public enum PublisherType
524+
{
525+
Online,
526+
Offline,
527+
Mixed
528+
}
474529
}

src/FluentNHibernate.Testing/DomainModel/Mapping/CompositeIdentityPartTester.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
2+
using System.Linq;
23
using FluentNHibernate.Mapping;
4+
using FluentNHibernate.Mapping.Providers;
5+
using FluentNHibernate.MappingModel.ClassBased;
36
using NUnit.Framework;
47

58
namespace FluentNHibernate.Testing.DomainModel.Mapping
@@ -160,6 +163,25 @@ public void MixedKeyPropertyAndManyToOneOrdering()
160163
.HasName("key-property");
161164
}
162165

166+
[Test]
167+
public void CompositeIdWithSubclass()
168+
{
169+
new MappingTester<CompIdTarget>()
170+
.SubClassMapping<ComIdSubclass>(s =>
171+
{
172+
s.Table("subclasstable");
173+
s.KeyColumn("subclass_longId");
174+
s.KeyColumn("subclass_nullablelongId");
175+
})
176+
.ForMapping(c => c.CompositeId()
177+
.KeyProperty(x => x.LongId)
178+
.KeyProperty(x => x.NullableLongId))
179+
.Element("class/joined-subclass/key/*[1]")
180+
.Exists().HasName("column").HasAttribute("name", "subclass_longId")
181+
.RootElement.Element("class/joined-subclass/key/*[2]")
182+
.Exists().HasName("column").HasAttribute("name", "subclass_nullablelongId");
183+
}
184+
163185
public class CompIdTarget
164186
{
165187
public virtual long LongId { get; set; }
@@ -170,6 +192,11 @@ public class CompIdTarget
170192
public virtual SomeEnum EnumProperty { get; set; }
171193
}
172194

195+
public class ComIdSubclass : CompIdTarget
196+
{
197+
198+
}
199+
173200
public enum SomeEnum
174201
{}
175202

@@ -183,5 +210,12 @@ public class ComponentKey
183210
public virtual int KeyCol1 { get; set; }
184211
public virtual int KeyCol2 { get; set; }
185212
}
213+
214+
[Test]
215+
public void Can_Have_Multiple_key_Columns()
216+
{
217+
var provider = (IIndeterminateSubclassMappingProvider)new MultipleKeyColumnsTester.TestMap();
218+
provider.GetSubclassMapping(SubclassType.JoinedSubclass).Key.Columns.Count().ShouldEqual(2);
219+
}
186220
}
187221
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using FluentNHibernate.Mapping;
6+
using FluentNHibernate.Mapping.Providers;
7+
using FluentNHibernate.MappingModel.ClassBased;
8+
using NUnit.Framework;
9+
10+
namespace FluentNHibernate.Testing.DomainModel.Mapping
11+
{
12+
[TestFixture]
13+
public class MultipleKeyColumnsTester
14+
{
15+
[Test]
16+
public void CanHaveMultipleKeyColumns()
17+
{
18+
var provider = (IIndeterminateSubclassMappingProvider)new TestMap();
19+
provider.GetSubclassMapping(SubclassType.JoinedSubclass).Key.Columns.Count().ShouldEqual(2);
20+
}
21+
22+
public class Base
23+
{
24+
public int Id { get; set; }
25+
}
26+
27+
public class TestMap : SubclassMap<Base>
28+
{
29+
public TestMap()
30+
{
31+
KeyColumn("col1");
32+
KeyColumn("col2");
33+
}
34+
}
35+
}
36+
}

src/FluentNHibernate.Testing/DomainModel/Mapping/PropertyPartTester.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,18 @@ public void CanSpecifyNotUpdate()
441441
.Element("class/property").HasAttribute("update", "false");
442442
}
443443

444+
[Test]
445+
public void MapNestedGeneric()
446+
{
447+
new MappingTester<OuterTarget<String>.NestedTarget>()
448+
.ForMapping(m =>
449+
{
450+
m.Id(x => x.Id);
451+
m.Map(x => x.Value);
452+
})
453+
.Element("class").HasAttribute("table", "`NestedTarget_String`");
454+
}
455+
444456
#region Custom IUserType impl for testing
445457
public class CustomTypeForTesting : IUserType
446458
{
@@ -609,6 +621,15 @@ public class ComponentTarget
609621
public object Name { get; set; }
610622
}
611623

624+
class OuterTarget<T>
625+
{
626+
public class NestedTarget
627+
{
628+
public virtual int Id { get; set; }
629+
public virtual T Value { get; set; }
630+
}
631+
}
632+
612633
public class FakePropertyAccessor : IPropertyAccessor
613634
{
614635
public IGetter GetGetter(Type theClass, string propertyName)

src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
<Compile Include="AutoMapping\Apm\ConcreteBaseClassTests.cs" />
105105
<Compile Include="AutoMapping\Apm\Conventions\VersionConventionTests.cs" />
106106
<Compile Include="AutoMapping\DefaultAutoMappingConfigurationTests.cs" />
107-
<Compile Include="AutoMapping\Apm\IdentityTests.cs" />
107+
<Compile Include="AutoMapping\Apm\IdentityTests.cs" />
108+
<Compile Include="AutoMapping\InheritanceTests.cs" />
108109
<Compile Include="AutoMapping\Overrides\ReferenceComponentOverrides.cs" />
109110
<Compile Include="AutoMapping\Overrides\AutoMappingOverrideAlterationTests.cs" />
110111
<Compile Include="AutoMapping\Apm\CacheOverrideTests.cs" />
@@ -125,6 +126,7 @@
125126
<Compile Include="AutoMapping\Overrides\CompositeIdOverrides.cs" />
126127
<Compile Include="AutoMapping\Overrides\HibernateMappingOverrides.cs" />
127128
<Compile Include="DomainModel\Mapping\ManyToManySelfReferencedInverseIntegrationTester.cs" />
129+
<Compile Include="DomainModel\Mapping\MultipleKeyColumnsTester.cs" />
128130
<Compile Include="DomainModel\MemberAccessResolverTests.cs" />
129131
<Compile Include="DomainModel\MemberBackingFieldTests.cs" />
130132
<Compile Include="DomainModel\NamingTests.cs" />

0 commit comments

Comments
 (0)