@@ -10,7 +10,7 @@ public class GeoShapeQueryTests : ParseQueryTestsBase
1010 {
1111
1212 [ Test ]
13- public void GeoShape_Deserializes ( )
13+ public void GeoShapeEnvelope_Deserializes ( )
1414 {
1515 var q = this . SerializeThenDeserialize (
1616 f => f . GeoShape ,
@@ -20,12 +20,191 @@ public void GeoShape_Deserializes()
2020 )
2121 ) ;
2222
23- q . Field . Should ( ) . Be ( "myGeoShape" ) ;
24- var envelopeQuery = q as IGeoShapeEnvelopeQuery ;
25- envelopeQuery . Should ( ) . NotBeNull ( ) ;
26- envelopeQuery . Shape . Type . Should ( ) . Be ( "envelope" ) ;
27- envelopeQuery . Shape . Coordinates . SelectMany ( c=> c ) . Should ( )
23+ var query = q as IGeoShapeEnvelopeQuery ;
24+ query . Should ( ) . NotBeNull ( ) ;
25+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
26+ query . Shape . Type . Should ( ) . Be ( "envelope" ) ;
27+ query . Shape . Coordinates . SelectMany ( c=> c ) . Should ( )
2828 . BeEquivalentTo ( new [ ] { 13.0 , 53.0 , 14.0 , 52.0 } ) ;
2929 }
30+
31+ [ Test ]
32+ public void GeoShapeCircle_Deserializes ( )
33+ {
34+ var coordinates = new [ ] { - 45.0 , 45.0 } ;
35+
36+ var q = this . SerializeThenDeserialize (
37+ f => f . GeoShape ,
38+ f => f . GeoShapeCircle ( gq => gq
39+ . OnField ( p => p . MyGeoShape )
40+ . Radius ( "100m" )
41+ . Coordinates ( coordinates )
42+ )
43+ ) ;
44+
45+ var query = q as IGeoShapeCircleQuery ;
46+ query . Should ( ) . NotBeNull ( ) ;
47+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
48+ query . Shape . Should ( ) . NotBeNull ( ) ;
49+ query . Shape . Type . Should ( ) . Be ( "circle" ) ;
50+ query . Shape . Radius . Should ( ) . Be ( "100m" ) ;
51+ query . Shape . Coordinates . Should ( ) . BeEquivalentTo ( coordinates ) ;
52+ }
53+
54+ [ Test ]
55+ public void GeoShapeLineString_Deserializes ( )
56+ {
57+ var coordinates = new [ ] { new [ ] { 13.0 , 53.0 } , new [ ] { 14.0 , 52.0 } } ;
58+
59+ var q = this . SerializeThenDeserialize (
60+ f => f . GeoShape ,
61+ f => f . GeoShapeLineString ( gq => gq
62+ . OnField ( p => p . MyGeoShape )
63+ . Coordinates ( coordinates )
64+ )
65+ ) ;
66+
67+ var query = q as IGeoShapeLineStringQuery ;
68+ query . Should ( ) . NotBeNull ( ) ;
69+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
70+ query . Shape . Should ( ) . NotBeNull ( ) ;
71+ query . Shape . Type . Should ( ) . Be ( "linestring" ) ;
72+ query . Shape . Coordinates . SelectMany ( c => c ) . Should ( )
73+ . BeEquivalentTo ( coordinates . SelectMany ( c => c ) ) ;
74+ }
75+
76+ [ Test ]
77+ public void GeoShapeMultiLineString_Deserializes ( )
78+ {
79+ var coordinates = new [ ]
80+ {
81+ new [ ] { new [ ] { 102.0 , 2.0 } , new [ ] { 103.0 , 2.0 } , new [ ] { 103.0 , 3.0 } , new [ ] { 102.0 , 3.0 } } ,
82+ new [ ] { new [ ] { 100.0 , 0.0 } , new [ ] { 101.0 , 0.0 } , new [ ] { 101.0 , 1.0 } , new [ ] { 100.0 , 1.0 } } ,
83+ new [ ] { new [ ] { 100.2 , 0.2 } , new [ ] { 100.8 , 0.2 } , new [ ] { 100.8 , 0.8 } , new [ ] { 100.2 , 0.8 } }
84+ } ;
85+
86+ var q = this . SerializeThenDeserialize (
87+ f => f . GeoShape ,
88+ f => f . GeoShapeMultiLineString ( gq => gq
89+ . OnField ( p => p . MyGeoShape )
90+ . Coordinates ( coordinates )
91+ )
92+ ) ;
93+
94+ var query = q as IGeoShapeMultiLineStringQuery ;
95+ query . Should ( ) . NotBeNull ( ) ;
96+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
97+ query . Shape . Should ( ) . NotBeNull ( ) ;
98+ query . Shape . Type . Should ( ) . Be ( "multilinestring" ) ;
99+ query . Shape . Coordinates . SelectMany ( c => c . SelectMany ( cc => cc ) ) . Should ( )
100+ . BeEquivalentTo ( coordinates . SelectMany ( c => c . SelectMany ( cc => cc ) ) ) ;
101+ }
102+
103+ [ Test ]
104+ public void GeoShapePoint_Deserializes ( )
105+ {
106+ var coordinates = new [ ] { 1.0 , 2.0 } ;
107+
108+ var q = this . SerializeThenDeserialize (
109+ f => f . GeoShape ,
110+ f => f . GeoShapePoint ( gq => gq
111+ . OnField ( p => p . MyGeoShape )
112+ . Coordinates ( coordinates )
113+ )
114+ ) ;
115+
116+ var query = q as IGeoShapePointQuery ;
117+ query . Should ( ) . NotBeNull ( ) ;
118+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
119+ query . Shape . Should ( ) . NotBeNull ( ) ;
120+ query . Shape . Type . Should ( ) . Be ( "point" ) ;
121+ query . Shape . Coordinates . Should ( ) . BeEquivalentTo ( coordinates ) ;
122+ }
123+
124+ [ Test ]
125+ public void GeoShapeMultiPoint_Deserializes ( )
126+ {
127+ var coordinates = new [ ] { new [ ] { 13.0 , 53.0 } , new [ ] { 14.0 , 52.0 } } ;
128+
129+ var q = this . SerializeThenDeserialize (
130+ f => f . GeoShape ,
131+ f => f . GeoShapeMultiPoint ( gq => gq
132+ . OnField ( p => p . MyGeoShape )
133+ . Coordinates ( coordinates )
134+ )
135+ ) ;
136+
137+ var query = q as IGeoShapeMultiPointQuery ;
138+ query . Should ( ) . NotBeNull ( ) ;
139+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
140+ query . Shape . Should ( ) . NotBeNull ( ) ;
141+ query . Shape . Type . Should ( ) . Be ( "multipoint" ) ;
142+ query . Shape . Coordinates . SelectMany ( c => c ) . Should ( )
143+ . BeEquivalentTo ( coordinates . SelectMany ( c => c ) ) ;
144+ }
145+
146+ [ Test ]
147+ public void GeoShapePolygon_Deserializes ( )
148+ {
149+ var coordinates = new [ ]
150+ {
151+ new [ ] { new [ ] { 100.0 , 0.0 } , new [ ] { 101.0 , 0.0 } , new [ ] { 101.0 , 1.0 } , new [ ] { 100.0 , 1.0 } , new [ ] { 100.0 , 0.0 } } ,
152+ new [ ] { new [ ] { 100.2 , 0.2 } , new [ ] { 100.8 , 0.2 } , new [ ] { 100.8 , 0.8 } , new [ ] { 100.2 , 0.8 } , new [ ] { 100.2 , 0.2 } }
153+ } ;
154+
155+ var q = this . SerializeThenDeserialize (
156+ f => f . GeoShape ,
157+ f => f . GeoShapePolygon ( gq => gq
158+ . OnField ( p => p . MyGeoShape )
159+ . Coordinates ( coordinates )
160+ )
161+ ) ;
162+
163+ var query = q as IGeoShapePolygonQuery ;
164+ query . Should ( ) . NotBeNull ( ) ;
165+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
166+ query . Shape . Should ( ) . NotBeNull ( ) ;
167+ query . Shape . Type . Should ( ) . Be ( "polygon" ) ;
168+ query . Shape . Coordinates . SelectMany ( c => c . SelectMany ( cc => cc ) ) . Should ( )
169+ . BeEquivalentTo ( coordinates . SelectMany ( c => c . SelectMany ( cc => cc ) ) ) ;
170+ }
171+
172+ [ Test ]
173+ public void GeoShapeMultiPolygon_Deserializes ( )
174+ {
175+ var coordinates = new [ ]
176+ {
177+ new [ ] {
178+ new [ ] {
179+ new [ ] { 102.0 , 2.0 } , new [ ] { 103.0 , 2.0 } , new [ ] { 103.0 , 3.0 } , new [ ] { 102.0 , 3.0 } , new [ ] { 102.0 , 2.0 }
180+ }
181+ } ,
182+ new [ ] {
183+ new [ ] {
184+ new [ ] { 100.0 , 0.0 } , new [ ] { 101.0 , 0.0 } , new [ ] { 101.0 , 1.0 } , new [ ] { 100.0 , 1.0 } , new [ ] { 100.0 , 0.0 }
185+ } ,
186+ new [ ] {
187+ new [ ] { 100.2 , 0.2 } , new [ ] { 100.8 , 0.2 } , new [ ] { 100.8 , 0.8 } , new [ ] { 100.2 , 0.8 } , new [ ] { 100.2 , 0.2 }
188+ }
189+ }
190+ } ;
191+
192+ var q = this . SerializeThenDeserialize (
193+ f => f . GeoShape ,
194+ f => f . GeoShapeMultiPolygon ( gq => gq
195+ . OnField ( p => p . MyGeoShape )
196+ . Coordinates ( coordinates )
197+ )
198+ ) ;
199+
200+ var query = q as IGeoShapeMultiPolygonQuery ;
201+ query . Should ( ) . NotBeNull ( ) ;
202+ query . Field . Should ( ) . Be ( "myGeoShape" ) ;
203+ query . Shape . Should ( ) . NotBeNull ( ) ;
204+ query . Shape . Type . Should ( ) . Be ( "multipolygon" ) ;
205+ query . Shape . Coordinates . SelectMany ( c => c . SelectMany ( cc => cc . SelectMany ( ccc => ccc ) ) ) . Should ( )
206+ . BeEquivalentTo ( coordinates . SelectMany ( c => c . SelectMany ( cc => cc . SelectMany ( ccc => ccc ) ) ) ) ;
207+ }
208+
30209 }
31210}
0 commit comments