xamarin-macios/tests/monotouch-test/MapKit/PolylineViewTest.cs

90 строки
2.0 KiB
C#
Исходник Обычный вид История

2016-05-26 16:06:52 +03:00
// Copyright 2011-2012 Xamarin Inc. All rights reserved
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC
2016-05-26 16:06:52 +03:00
using System;
using System.Drawing;
using System.Reflection;
using CoreGraphics;
2016-05-26 16:06:52 +03:00
using Foundation;
using MapKit;
using NUnit.Framework;
namespace MonoTouchFixtures.MapKit {
#if !XAMCORE_3_0
2016-05-26 16:06:52 +03:00
class PolylineViewPoker : MKPolylineView {
static FieldInfo bkPolyline;
static PolylineViewPoker ()
{
var t = typeof (MKPolylineView);
bkPolyline = t.GetField ("__mt_Polyline_var", BindingFlags.Instance | BindingFlags.NonPublic);
}
public static bool NewRefcountEnabled ()
{
return NSObject.IsNewRefcountEnabled ();
}
public PolylineViewPoker ()
{
}
public PolylineViewPoker (MKPolyline polyline) : base (polyline)
{
}
public MKPolyline PolylineBackingField {
get {
return (MKPolyline) bkPolyline.GetValue (this);
}
}
}
#endif // !XAMCORE_3_0
2016-05-26 16:06:52 +03:00
[TestFixture]
[Preserve (AllMembers = true)]
public class PolylineViewTest {
[Test]
public void InitWithFrame ()
{
var frame = new CGRect (10, 10, 100, 100);
2016-05-26 16:06:52 +03:00
using (MKPolylineView pl = new MKPolylineView (frame)) {
Assert.That (pl.Frame, Is.EqualTo (frame), "Frame");
}
}
#if !XAMCORE_3_0
2016-05-26 16:06:52 +03:00
[Test]
public void Defaults_BackingFields ()
{
if (PolylineViewPoker.NewRefcountEnabled ())
Assert.Inconclusive ("backing fields are removed when newrefcount is enabled");
using (var pv = new PolylineViewPoker ()) {
Assert.Null (pv.PolylineBackingField, "1a");
Assert.Null (pv.Polyline, "2a");
}
}
[Test]
public void Polygon_BackingFields ()
{
if (PolylineViewPoker.NewRefcountEnabled ())
Assert.Inconclusive ("backing fields are removed when newrefcount is enabled");
using (var p = new MKPolyline ())
using (var pv = new PolylineViewPoker (p)) {
Assert.AreSame (p, pv.PolylineBackingField, "1a");
Assert.AreSame (p, pv.Polyline, "2a");
}
}
#endif // !XAMCORE_3_0
2016-05-26 16:06:52 +03:00
}
}
#endif // !__TVOS__ && !__WATCHOS__