Skip to content

Commit e7efe21

Browse files
committed
Moved the broken external component output specs to the spec project and fixed it to use mspec.
1 parent 84a3f52 commit e7efe21

File tree

4 files changed

+45
-31
lines changed

4 files changed

+45
-31
lines changed

src/FluentNHibernate.Specs/Extensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
5+
using System.Xml;
56
using FluentNHibernate.MappingModel.ClassBased;
67
using Machine.Specifications;
78

@@ -30,5 +31,17 @@ public static ClassMapping BuildMappingFor<T>(this FluentNHibernate.PersistenceM
3031
.SelectMany(x => x.Classes)
3132
.FirstOrDefault(x => x.Type == typeof(T));
3233
}
34+
35+
public static void OutputXmlToConsole(this XmlDocument document)
36+
{
37+
var stringWriter = new System.IO.StringWriter();
38+
var xmlWriter = new XmlTextWriter(stringWriter);
39+
xmlWriter.Formatting = Formatting.Indented;
40+
document.WriteContentTo(xmlWriter);
41+
42+
Console.WriteLine(string.Empty);
43+
Console.WriteLine(stringWriter.ToString());
44+
Console.WriteLine(string.Empty);
45+
}
3346
}
3447
}

src/FluentNHibernate.Testing/MappingModel/Output/ExternalComponentOutputSpecs.cs renamed to src/FluentNHibernate.Specs/FluentInterface/ExternalComponentOutputSpecs.cs

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,66 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Linq;
34
using FluentNHibernate.Mapping;
45
using FluentNHibernate.MappingModel.Output;
5-
using NUnit.Framework;
6+
using Machine.Specifications;
7+
using Machine.Specifications.Model;
68

7-
namespace FluentNHibernate.Testing.MappingModel.Output
9+
namespace FluentNHibernate.Specs.FluentInterface
810
{
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
1112
{
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 = () =>
1914
{
2015
inline_component = new ClassMap<Target>();
16+
inline_component.Id(x => x.Id);
2117
inline_component.Component(x => x.ComponentProperty1, c => c.Map(x => x.Property));
2218
inline_component.Component(x => x.ComponentProperty2, c => c.Map(x => x.Property));
2319

2420
external_component = new ComponentMap<Component>();
2521
external_component.Map(x => x.Property);
2622

2723
reference_component = new ClassMap<Target>();
24+
reference_component.Id(x => x.Id);
2825
reference_component.Component(x => x.ComponentProperty1);
2926
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+
};
4328

44-
public override void because()
29+
Because of = () =>
4530
{
4631
inline_xml = render_xml(x => x.Add(inline_component));
4732
referenced_xml = render_xml(x =>
4833
{
4934
x.Add(reference_component);
5035
x.Add(external_component);
5136
});
52-
}
37+
};
5338

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 = () =>
5740
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;
5953
}
6054

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+
6161
private class Target
6262
{
63+
public int Id { get; set;}
6364
public Component ComponentProperty1 { get; set; }
6465
public Component ComponentProperty2 { get; set; }
6566
}

src/FluentNHibernate.Specs/FluentNHibernate.Specs.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
</ItemGroup>
145145
<ItemGroup>
146146
<Compile Include="Automapping\AutomappingSpecs.NestedClasses.cs" />
147+
<Compile Include="FluentInterface\ExternalComponentOutputSpecs.cs" />
147148
</ItemGroup>
148149
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
149150
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@
168168
<Compile Include="MappingModel\Equality\CollectionContentEqualitySpecs.cs" />
169169
<Compile Include="MappingModel\Defaults\MutableDefaultsTester.cs" />
170170
<Compile Include="MappingModel\Equality\MappingEqualitySpecs.cs" />
171-
<Compile Include="MappingModel\Output\ExternalComponentOutputSpecs.cs" />
172171
<Compile Include="MappingModel\Output\XmlDiscriminatorWriterTester.cs" />
173172
<Compile Include="MappingModel\Output\XmlFilterDefinitionWriterTester.cs" />
174173
<Compile Include="MappingModel\Output\XmlFilterWriterTester.cs" />

0 commit comments

Comments
 (0)