Skip to content

NH-3491 - Add test case #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/NH3491/FixtureByCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping.ByCode;
using NUnit.Framework;
using System.Linq;

namespace NHibernate.Test.NHSpecificTest.NH3491
{
[TestFixture]
public class FixtureByCode
{
class SomeComponent
{
public virtual string PropertyOne { get; set; }
public virtual string PropertyTwo { get; set; }
public virtual string PropertyThree { get; set; }
}

class ClassWithComponents
{
public virtual Guid Id { get; set; }

public virtual SomeComponent Component1 { get; set; }

public virtual SomeComponent Component2 { get; set; }
}

[Test(Description = "NH-3491"), KnownBug("NH-3491")]
public void ShouldProperlyMapComponentWhenMappingOnlyPartOfItInSomePlaces()
{
var mapper = new ModelMapper();
mapper.Class<ClassWithComponents>(cm =>
{
cm.Component(x => x.Component1, c =>
{
c.Property(x => x.PropertyOne, p => p.Column("OnePropertyOne"));
});

cm.Component(x => x.Component2, c =>
{
c.Property(x => x.PropertyOne, p => p.Column("TwoPropertyOne"));
c.Property(x => x.PropertyTwo, p => p.Column("TwoPropertyTwo"));
});
});

//Compile, and get the component property in which we mapped only one inner property
var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities();

var component1PropertyMapping = (HbmComponent)mappings.RootClasses[0].Properties.Single(x => x.Name == "Component1");

//There should be only one inner property in the mapping of this component
// Note: take a look at how CURRENTLY the test fails with 1 expected vs 2, instead of vs 3.
// This means that the "PropertyThree" property of the component that was never mapped, is not taken into account (which is fine).
Assert.That(component1PropertyMapping.Items.Length, Is.EqualTo(1));
}
}
}
1 change: 1 addition & 0 deletions src/NHibernate.Test/NHibernate.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@
<Compile Include="NHSpecificTest\NH3487\Fixture.cs" />
<Compile Include="NHSpecificTest\NH3567\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH3567\NH3567Tests.cs" />
<Compile Include="NHSpecificTest\NH3491\FixtureByCode.cs" />
<Compile Include="NHSpecificTest\NH3570\BiFixture.cs" />
<Compile Include="NHSpecificTest\NH3570\Model.cs" />
<Compile Include="NHSpecificTest\NH3570\UniFixture.cs" />
Expand Down