22using FluentAssertions ;
33using FluentCommand . SqlServer . Tests ;
44using Microsoft . Extensions . Logging . Abstractions ;
5+ using System . IO ;
56using Xunit ;
67using Xunit . Abstractions ;
78
@@ -26,6 +27,7 @@ public void Generate()
2627 result . Should ( ) . BeTrue ( ) ;
2728 }
2829
30+
2931 [ Fact ]
3032 public void Generate_Should_Work_For_Password_With_CurlyBrace ( )
3133 {
@@ -38,4 +40,39 @@ public void Generate_Should_Work_For_Password_With_CurlyBrace()
3840
3941 result . Should ( ) . BeTrue ( ) ;
4042 }
43+ [ Fact ]
44+ public void GenerateSpatial ( )
45+ {
46+ var generatorOptions = new GeneratorOptions ( ) ;
47+ generatorOptions . Database . ConnectionString = Database . ConnectionString ;
48+
49+ var generator = new CodeGenerator ( NullLoggerFactory . Instance ) ;
50+ var result = generator . Generate ( generatorOptions ) ;
51+
52+ result . Should ( ) . BeTrue ( ) ;
53+
54+ const string spatialTableName = "CitiesSpatial" ;
55+
56+ var citiesSpatialEntityFile = Path . Combine ( generatorOptions . Data . Entity . Directory , spatialTableName + ".cs" ) ;
57+ var citiesSpatialMappingFile = Path . Combine ( generatorOptions . Data . Mapping . Directory , spatialTableName + "Map.cs" ) ;
58+
59+ var citiesSpatialEntityContent = File . ReadAllText ( citiesSpatialEntityFile ) ;
60+ var citiesSpatialMappingContent = File . ReadAllText ( citiesSpatialMappingFile ) ;
61+
62+ citiesSpatialEntityContent . Contains ( "public NetTopologySuite.Geometries.Geometry GeometryField { get; set; }" ) . Should ( ) . BeTrue ( ) ;
63+ citiesSpatialEntityContent . Contains ( "public NetTopologySuite.Geometries.Geometry GeographyField { get; set; }" ) . Should ( ) . BeTrue ( ) ;
64+
65+ citiesSpatialMappingContent . Contains ( "builder.Property(t => t.GeometryField)" + System . Environment . NewLine +
66+ " .IsRequired()" + System . Environment . NewLine +
67+ " .HasColumnName(\" GeometryField\" )" + System . Environment . NewLine +
68+ " .HasColumnType(\" geometry\" );" ) . Should ( ) . BeTrue ( ) ;
69+
70+ citiesSpatialMappingContent . Contains ( "builder.Property(t => t.GeographyField)" + System . Environment . NewLine +
71+ " .IsRequired()" + System . Environment . NewLine +
72+ " .HasColumnName(\" GeographyField\" )" + System . Environment . NewLine +
73+ " .HasColumnType(\" geography\" );" ) . Should ( ) . BeTrue ( ) ;
74+
75+ }
76+
4177}
78+
0 commit comments