@@ -25,13 +25,14 @@ public void LongitudeRefAndLatitudeRefTest ()
2525 string expectedLongitudeRef = "W" ;
2626 string file = Path . Combine ( NSBundle . MainBundle . ResourcePath , "basn3p08_with_loc.png" ) ;
2727
28- using var url = NSUrl . FromFilename ( file ) ;
29- using var ci = CIImage . FromUrl ( url ) ;
30- var gps = ci . Properties . Gps ;
31- Assert . That ( gps . Latitude , Is . EqualTo ( expectedLatitude ) . Within ( 0.0001f ) , "Invalid or no Latitude value found." ) ;
32- Assert . That ( gps . Longitude , Is . EqualTo ( expectedLongitude ) . Within ( 0.0001f ) , "Invalid or no Longitude value found." ) ;
33- Assert . That ( gps . LatitudeRef , Is . EqualTo ( expectedLatitudeRef ) , "Invalid or no LatitudeRef value found." ) ;
34- Assert . That ( gps . LongitudeRef , Is . EqualTo ( expectedLongitudeRef ) , "Invalid or no LongitudeRef value found." ) ;
28+ using ( var url = NSUrl . FromFilename ( file ) )
29+ using ( var ci = CIImage . FromUrl ( url ) ) {
30+ var gps = ci . Properties . Gps ;
31+ Assert . That ( gps . Latitude , Is . EqualTo ( expectedLatitude ) . Within ( 0.0001f ) , "Invalid or no Latitude value found." ) ;
32+ Assert . That ( gps . Longitude , Is . EqualTo ( expectedLongitude ) . Within ( 0.0001f ) , "Invalid or no Longitude value found." ) ;
33+ Assert . That ( gps . LatitudeRef , Is . EqualTo ( expectedLatitudeRef ) , "Invalid or no LatitudeRef value found." ) ;
34+ Assert . That ( gps . LongitudeRef , Is . EqualTo ( expectedLongitudeRef ) , "Invalid or no LongitudeRef value found." ) ;
35+ }
3536 }
3637
3738 [ Test ]
@@ -61,39 +62,41 @@ public void ConstructorAndBasicPropertiesTest ()
6162 [ Test ]
6263 public void ConstructorWithDictionaryTest ( )
6364 {
64- using var dict = new NSMutableDictionary ( ) ;
65- var gps = new CGImagePropertiesGps ( dict ) ;
66- Assert . That ( gps , Is . Not . Null , "Constructor with dictionary should create a valid instance" ) ;
65+ using ( var dict = new NSMutableDictionary ( ) ) {
66+ var gps = new CGImagePropertiesGps ( dict ) ;
67+ Assert . That ( gps , Is . Not . Null , "Constructor with dictionary should create a valid instance" ) ;
68+ }
6769 }
6870
6971 [ Test ]
7072 public void IntegrationWithCGImagePropertiesTest ( )
7173 {
7274 // Test that CGImageProperties can access GPS properties
7375 string file = Path . Combine ( NSBundle . MainBundle . ResourcePath , "basn3p08.png" ) ;
74-
75- using var url = NSUrl . FromFilename ( file ) ;
76- using var ci = CIImage . FromUrl ( url ) ;
77- var imageProps = ci . Properties ;
78- Assert . That ( imageProps , Is . Not . Null , "Image properties should be available" ) ;
79-
80- // Note: The regular PNG may not have GPS data, so Gps property could be null
81- // This test mainly verifies the property access doesn't throw exceptions
82- var gps = imageProps . Gps ;
83- // gps may be null for PNG files without GPS data, which is expected
76+
77+ using ( var url = NSUrl . FromFilename ( file ) )
78+ using ( var ci = CIImage . FromUrl ( url ) ) {
79+ var imageProps = ci . Properties ;
80+ Assert . That ( imageProps , Is . Not . Null , "Image properties should be available" ) ;
81+
82+ // Note: The regular PNG may not have GPS data, so Gps property could be null
83+ // This test mainly verifies the property access doesn't throw exceptions
84+ var gps = imageProps . Gps ;
85+ // gps may be null for PNG files without GPS data, which is expected
86+ }
8487 }
8588
8689 [ Test ]
8790 public void NegativeCoordinatesTest ( )
8891 {
8992 var gps = new CGImagePropertiesGps ( ) ;
90-
93+
9194 // Test negative coordinates (southern hemisphere and western longitude)
9295 gps . Latitude = - 33.8688f ; // Sydney latitude
9396 gps . Longitude = 151.2093f ; // Sydney longitude
9497 Assert . That ( gps . Latitude , Is . EqualTo ( - 33.8688f ) . Within ( 0.0001f ) , "Should handle negative latitude" ) ;
9598 Assert . That ( gps . Longitude , Is . EqualTo ( 151.2093f ) . Within ( 0.0001f ) , "Should handle positive longitude" ) ;
96-
99+
97100 gps . LatitudeRef = "S" ;
98101 gps . LongitudeRef = "E" ;
99102 Assert . That ( gps . LatitudeRef , Is . EqualTo ( "S" ) , "Should handle southern hemisphere" ) ;
@@ -104,14 +107,14 @@ public void NegativeCoordinatesTest ()
104107 public void AltitudeTest ( )
105108 {
106109 var gps = new CGImagePropertiesGps ( ) ;
107-
110+
108111 // Test various altitude values
109112 gps . Altitude = 0 ; // Sea level
110113 Assert . That ( gps . Altitude , Is . EqualTo ( 0 ) , "Should handle sea level altitude" ) ;
111-
114+
112115 gps . Altitude = 8849 ; // Mount Everest height in meters
113116 Assert . That ( gps . Altitude , Is . EqualTo ( 8849 ) , "Should handle high altitude" ) ;
114-
117+
115118 gps . Altitude = - 400 ; // Below sea level
116119 Assert . That ( gps . Altitude , Is . EqualTo ( - 400 ) , "Should handle negative altitude" ) ;
117120 }
@@ -120,20 +123,20 @@ public void AltitudeTest ()
120123 public void NullablePropertiesTest ( )
121124 {
122125 var gps = new CGImagePropertiesGps ( ) ;
123-
126+
124127 // Test that nullable properties can be set to null
125128 gps . Latitude = null ;
126129 Assert . That ( gps . Latitude , Is . Null , "Latitude should be nullable" ) ;
127-
130+
128131 gps . Longitude = null ;
129132 Assert . That ( gps . Longitude , Is . Null , "Longitude should be nullable" ) ;
130-
133+
131134 gps . Altitude = null ;
132135 Assert . That ( gps . Altitude , Is . Null , "Altitude should be nullable" ) ;
133-
136+
134137 gps . LatitudeRef = null ;
135138 Assert . That ( gps . LatitudeRef , Is . Null , "LatitudeRef should be nullable" ) ;
136-
139+
137140 gps . LongitudeRef = null ;
138141 Assert . That ( gps . LongitudeRef , Is . Null , "LongitudeRef should be nullable" ) ;
139142 }
@@ -142,13 +145,13 @@ public void NullablePropertiesTest ()
142145 public void EdgeCaseCoordinatesTest ( )
143146 {
144147 var gps = new CGImagePropertiesGps ( ) ;
145-
148+
146149 // Test edge case coordinates
147150 gps . Latitude = 90.0f ; // North pole
148151 gps . Longitude = 180.0f ; // International date line
149152 Assert . That ( gps . Latitude , Is . EqualTo ( 90.0f ) . Within ( 0.0001f ) , "Should handle north pole latitude" ) ;
150153 Assert . That ( gps . Longitude , Is . EqualTo ( 180.0f ) . Within ( 0.0001f ) , "Should handle international date line longitude" ) ;
151-
154+
152155 gps . Latitude = - 90.0f ; // South pole
153156 gps . Longitude = - 180.0f ; // International date line (west)
154157 Assert . That ( gps . Latitude , Is . EqualTo ( - 90.0f ) . Within ( 0.0001f ) , "Should handle south pole latitude" ) ;
0 commit comments