-
Notifications
You must be signed in to change notification settings - Fork 684
Improper matching performed in RelationshipPairingVisitor's PairOneToManys #313
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8a1e48f
Added a test for RelationshipPairingVisitor that fails
Ignition 6a16f84
Fix for PairOneToManys
Ignition 35f783e
Fixed RakeFile for the new RelationshipPairingVisitor test
Ignition e4aeb09
Removed unneeded abstract class and fixed naming of variables
Ignition File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/FluentNHibernate.Testing/Visitors/RelationshipPairingVisitorSpec.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System.Linq; | ||
using FakeItEasy; | ||
using FluentNHibernate.MappingModel; | ||
using FluentNHibernate.MappingModel.Collections; | ||
using FluentNHibernate.Visitors; | ||
using NUnit.Framework; | ||
|
||
namespace FluentNHibernate.Testing.Visitors | ||
{ | ||
public abstract class RelationshipPairingVisitorSpec : Specification | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe abstract class is not necessary here. If we had several test cases that can share the functionality - sure |
||
{ | ||
protected RelationshipPairingVisitor visitor; | ||
protected CollectionMapping collectionMappingToZ; | ||
protected ManyToOneMapping manyToOneZToHolder; | ||
protected ManyToOneMapping manyToOneYToHolder; | ||
} | ||
|
||
[TestFixture] | ||
public class when_the_relationship_pairing_visitor_visits_with_multiple_many_to_one_mapping_references : RelationshipPairingVisitorSpec | ||
{ | ||
public override void establish_context() | ||
{ | ||
manyToOneYToHolder = new ManyToOneMapping(); | ||
manyToOneYToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder))); | ||
manyToOneYToHolder.Set(x => x.Name, Layer.Defaults, "ARankedFirstProperty"); | ||
manyToOneYToHolder.ContainingEntityType = typeof(ARankedFirst); | ||
manyToOneYToHolder.Member = new PropertyMember(typeof(ARankedFirst).GetProperty("ARankedFirstProperty")); | ||
|
||
manyToOneZToHolder = new ManyToOneMapping(); | ||
manyToOneZToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder))); | ||
manyToOneZToHolder.Set(x => x.Name, Layer.Defaults, "BRankedSecondProperty"); | ||
manyToOneZToHolder.ContainingEntityType = typeof(BRankedSecond); | ||
manyToOneZToHolder.Member = new PropertyMember(typeof(BRankedSecond).GetProperty("BRankedSecondProperty")); | ||
|
||
var relationship = new OneToManyMapping(); | ||
relationship.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(BRankedSecond))); | ||
relationship.ContainingEntityType = typeof(Holder); | ||
|
||
collectionMappingToZ = CollectionMapping.Bag(); | ||
collectionMappingToZ.Set(x => x.ChildType, Layer.Defaults, typeof(BRankedSecond)); | ||
collectionMappingToZ.Set(x => x.Name, Layer.Defaults, "ColectionOfBRankedSeconds"); | ||
collectionMappingToZ.Set(x => x.Relationship, Layer.Defaults, relationship); | ||
collectionMappingToZ.ContainingEntityType = typeof(Holder); | ||
|
||
visitor = new RelationshipPairingVisitor(A.Fake<PairBiDirectionalManyToManySidesDelegate>()); | ||
} | ||
|
||
[Test] | ||
public void should_associate_the_collection_mapping_to_the_correct_type() | ||
{ | ||
visitor.ProcessCollection(collectionMappingToZ); | ||
visitor.ProcessManyToOne(manyToOneYToHolder); | ||
visitor.ProcessManyToOne(manyToOneZToHolder); | ||
visitor.Visit(Enumerable.Empty<HibernateMapping>()); | ||
|
||
var otherSide = (ManyToOneMapping)collectionMappingToZ.OtherSide; | ||
otherSide.ContainingEntityType.ShouldEqual(typeof(BRankedSecond)); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/FluentNHibernate.Testing/Visitors/RelationshipPairingVisitorSpecSupportClasses.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FluentNHibernate.Testing.Visitors | ||
{ | ||
public class Holder | ||
{ | ||
public virtual ICollection<BRankedSecond> ColectionOfBRankedSeconds { get; set; } | ||
} | ||
|
||
public class BRankedSecond | ||
{ | ||
public virtual Holder BRankedSecondProperty { get; set; } | ||
} | ||
|
||
public class ARankedFirst | ||
{ | ||
public virtual Holder ARankedFirstProperty { get; set; } | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why InternalsVisibleTo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see - because you used PropertyMember