File tree Expand file tree Collapse file tree
GeoJSON.Net.Tests/Geometry Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
12using System . Collections . Generic ;
23using GeoJSON . Net . Geometry ;
34using Newtonsoft . Json ;
@@ -39,6 +40,7 @@ public void Is_Not_Closed()
3940
4041 Assert . IsFalse ( lineString . IsClosed ( ) ) ;
4142 }
43+
4244
4345 [ Test ]
4446 public void Can_Serialize ( )
@@ -81,6 +83,19 @@ public void Can_Deserialize()
8183 Assert . AreEqual ( expectedLineString . Coordinates [ 0 ] . Longitude , actualLineString . Coordinates [ 0 ] . Longitude ) ;
8284 }
8385
86+ [ Test ]
87+ public void Constructor_No_Coordinates_Throws_Exception ( )
88+ {
89+ var coordinates = new List < IPosition > ( ) ;
90+ Assert . Throws < ArgumentOutOfRangeException > ( ( ) => new LineString ( coordinates ) ) ;
91+ }
92+
93+ [ Test ]
94+ public void Constructor_Null_Coordinates_Throws_Exception ( )
95+ {
96+ Assert . Throws < ArgumentNullException > ( ( ) => new LineString ( null ) ) ;
97+ }
98+
8499 private LineString GetLineString ( double offset = 0.0 )
85100 {
86101 var coordinates = new List < IPosition >
Original file line number Diff line number Diff line change @@ -65,18 +65,12 @@ public LineString(IEnumerable<IPosition> coordinates)
6565 /// </returns>
6666 public bool IsClosed ( )
6767 {
68- var firstCoordinate = Coordinates [ 0 ] as Position ;
68+ var firstCoordinate = Coordinates [ 0 ] ;
69+ var lastCoordinate = Coordinates [ Coordinates . Count - 1 ] ;
6970
70- if ( firstCoordinate != null )
71- {
72- var lastCoordinate = Coordinates [ Coordinates . Count - 1 ] as Position ;
73-
74- return firstCoordinate . Latitude == lastCoordinate . Latitude
75- && firstCoordinate . Longitude == lastCoordinate . Longitude
76- && firstCoordinate . Altitude == lastCoordinate . Altitude ;
77- }
78-
79- return Coordinates [ 0 ] . Equals ( Coordinates [ Coordinates . Count - 1 ] ) ;
71+ return firstCoordinate . Longitude . Equals ( lastCoordinate . Longitude )
72+ && firstCoordinate . Latitude . Equals ( lastCoordinate . Latitude )
73+ && firstCoordinate . Altitude . Equals ( lastCoordinate . Altitude ) ;
8074 }
8175
8276 /// <summary>
You can’t perform that action at this time.
0 commit comments