|
1 | 1 | using System;
|
| 2 | +using System.Diagnostics; |
2 | 3 | using System.Linq;
|
3 | 4 | using FluentNHibernate.Mapping;
|
4 | 5 | using FluentNHibernate.MappingModel.Output;
|
5 |
| -using NUnit.Framework; |
| 6 | +using Machine.Specifications; |
| 7 | +using Machine.Specifications.Model; |
6 | 8 |
|
7 |
| -namespace FluentNHibernate.Testing.MappingModel.Output |
| 9 | +namespace FluentNHibernate.Specs.FluentInterface |
8 | 10 | {
|
9 |
| - [TestFixture] |
10 |
| - public class when_generating_the_output_for_a_resolved_component_reference : Specification |
| 11 | + public class when_generating_the_output_for_a_resolved_component_reference |
11 | 12 | {
|
12 |
| - private ClassMap<Target> inline_component; |
13 |
| - private ClassMap<Target> reference_component; |
14 |
| - private ComponentMap<Component> external_component; |
15 |
| - private string inline_xml; |
16 |
| - private string referenced_xml; |
17 |
| - |
18 |
| - public override void establish_context() |
| 13 | + Establish context = () => |
19 | 14 | {
|
20 | 15 | inline_component = new ClassMap<Target>();
|
| 16 | + inline_component.Id(x => x.Id); |
21 | 17 | inline_component.Component(x => x.ComponentProperty1, c => c.Map(x => x.Property));
|
22 | 18 | inline_component.Component(x => x.ComponentProperty2, c => c.Map(x => x.Property));
|
23 | 19 |
|
24 | 20 | external_component = new ComponentMap<Component>();
|
25 | 21 | external_component.Map(x => x.Property);
|
26 | 22 |
|
27 | 23 | reference_component = new ClassMap<Target>();
|
| 24 | + reference_component.Id(x => x.Id); |
28 | 25 | reference_component.Component(x => x.ComponentProperty1);
|
29 | 26 | reference_component.Component(x => x.ComponentProperty2);
|
30 |
| - } |
31 |
| - |
32 |
| - private string render_xml(Action<PersistenceModel> addMappings) |
33 |
| - { |
34 |
| - var model = new PersistenceModel(); |
35 |
| - |
36 |
| - addMappings(model); |
37 |
| - |
38 |
| - var mappings = model.BuildMappings(); |
39 |
| - var doc = new MappingXmlSerializer().Serialize(mappings.First()); |
40 |
| - |
41 |
| - return doc.OuterXml; |
42 |
| - } |
| 27 | + }; |
43 | 28 |
|
44 |
| - public override void because() |
| 29 | + Because of = () => |
45 | 30 | {
|
46 | 31 | inline_xml = render_xml(x => x.Add(inline_component));
|
47 | 32 | referenced_xml = render_xml(x =>
|
48 | 33 | {
|
49 | 34 | x.Add(reference_component);
|
50 | 35 | x.Add(external_component);
|
51 | 36 | });
|
52 |
| - } |
| 37 | + }; |
53 | 38 |
|
54 |
| - [Test] |
55 |
| - public void should_be_rendered_the_same_as_an_inline_component() |
56 |
| - { |
| 39 | + It should_be_rendered_the_same_as_an_inline_component = () => |
57 | 40 | referenced_xml.ShouldEqual(inline_xml);
|
58 |
| - System.Diagnostics.Debug.WriteLine(referenced_xml); |
| 41 | + |
| 42 | + |
| 43 | + private static string render_xml(Action<FluentNHibernate.PersistenceModel> addMappings) |
| 44 | + { |
| 45 | + var model = new FluentNHibernate.PersistenceModel(); |
| 46 | + |
| 47 | + addMappings(model); |
| 48 | + |
| 49 | + var mappings = model.BuildMappings(); |
| 50 | + var doc = new MappingXmlSerializer().Serialize(mappings.First()); |
| 51 | + |
| 52 | + return doc.OuterXml; |
59 | 53 | }
|
60 | 54 |
|
| 55 | + private static ClassMap<Target> inline_component; |
| 56 | + private static ClassMap<Target> reference_component; |
| 57 | + private static ComponentMap<Component> external_component; |
| 58 | + private static string inline_xml; |
| 59 | + private static string referenced_xml; |
| 60 | + |
61 | 61 | private class Target
|
62 | 62 | {
|
| 63 | + public int Id { get; set;} |
63 | 64 | public Component ComponentProperty1 { get; set; }
|
64 | 65 | public Component ComponentProperty2 { get; set; }
|
65 | 66 | }
|
|
0 commit comments