public void Overlays()
        {
            using (var polygon = new MKPolygon())
                using (var polyline = new MKPolyline())
                    using (var circle = new MKCircle())
                        using (MKMapView mv = new MKMapView()) {
                            // old API accepted NSObject (limited protocol support)
                            mv.AddOverlay(polygon);
                            Assert.That(mv.Overlays.Length, Is.EqualTo(1), "1");
                            mv.RemoveOverlay(polygon);
                            Assert.That(mv.Overlays, Is.Empty, "2");

#if XAMCORE_2_0
                            IMKOverlay[] list = { polygon, polyline, circle };
#else
                            NSObject[] list = { polygon, polyline, circle };
#endif
                            mv.AddOverlays(list);
                            Assert.That(mv.Overlays.Length, Is.EqualTo(3), "3");
                            mv.RemoveOverlays(list);
                            Assert.That(mv.Overlays, Is.Empty, "4");
                        }
        }
Exemple #2
0
        public void Overlays7()
        {
            TestRuntime.AssertXcodeVersion(5, 0, 1);

            using (var polygon = new MKPolygon())
                using (var polyline = new MKPolyline())
                    using (var circle = new MKCircle())
                        using (var tile = new MKTileOverlay())
                            using (MKMapView mv = new MKMapView()) {
                                // new API accepted MKOverlay (better protocol support)
                                mv.AddOverlay(polygon, MKOverlayLevel.AboveLabels);
                                mv.AddOverlay(tile, MKOverlayLevel.AboveLabels);
                                Assert.That(mv.Overlays.Length, Is.EqualTo(2), "1");
                                mv.RemoveOverlay(tile);
                                mv.RemoveOverlay(polygon);
                                Assert.That(mv.Overlays, Is.Empty, "2");

                                IMKOverlay[] list = { polygon, polyline, circle, tile };
                                mv.AddOverlays(list, MKOverlayLevel.AboveRoads);
                                Assert.That(mv.Overlays.Length, Is.EqualTo(4), "3");
                                mv.RemoveOverlays(list);
                                Assert.That(mv.Overlays, Is.Empty, "4");
                            }
        }