|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.Linq;
|
| 4 | +using System.Reflection; |
4 | 5 | using FluentNHibernate.Automapping;
|
5 | 6 | using FluentNHibernate.MappingModel.ClassBased;
|
6 | 7 | using FluentNHibernate.Specs.Automapping.Fixtures;
|
@@ -55,6 +56,39 @@ public override bool ShouldMap(Type type)
|
55 | 56 | }
|
56 | 57 | }
|
57 | 58 | }
|
| 59 | + |
| 60 | + public class when_automapper_is_told_to_map_a_class_with_a_nested_classes |
| 61 | + { |
| 62 | + Establish context = () => |
| 63 | + { |
| 64 | + nonPublicNestedType = typeof(PersonCard).GetNestedTypes(BindingFlags.NonPublic).Single(); |
| 65 | + model = AutoMap.Source(new StubTypeSource(typeof(PersonCard), typeof(PersonCard.PublicAddress), nonPublicNestedType), |
| 66 | + new DefaultAutomappingConfiguration()); |
| 67 | + }; |
| 68 | + |
| 69 | + Because of = () => mappings = model.BuildMappings().SelectMany(m => m.Classes); |
| 70 | + It should_map_public_nested_class = () => mappings.ShouldContain(m => m.Type == typeof(PersonCard.PublicAddress)); |
| 71 | + It should_not_map_not_public_nested_class = () => mappings.ShouldNotContain(m => m.Type == nonPublicNestedType); |
| 72 | + |
| 73 | + static AutoPersistenceModel model; |
| 74 | + static DefaultAutomappingConfiguration configuration; |
| 75 | + static Type nonPublicNestedType; |
| 76 | + static IEnumerable<ClassMapping> mappings; |
| 77 | + } |
| 78 | + |
| 79 | + public class PersonCard |
| 80 | + { |
| 81 | + public int Id { get; set; } |
| 82 | + public class PublicAddress |
| 83 | + { |
| 84 | + public int Id { get; set; } |
| 85 | + } |
| 86 | + private class PrivateAddress |
| 87 | + { |
| 88 | + public int Id { get; set; } |
| 89 | + } |
| 90 | + } |
| 91 | + |
58 | 92 | public class Order
|
59 | 93 | {
|
60 | 94 | public int Id { get; set; }
|
|
0 commit comments