2017-01-18 15:04:13 +03:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NUnit.Framework;
|
2016-09-26 23:29:47 +03:00
|
|
|
|
|
|
|
|
|
namespace Xamarin.Forms.Xaml.UnitTests
|
|
|
|
|
{
|
|
|
|
|
public partial class CompiledTypeConverter : ContentPage
|
|
|
|
|
{
|
|
|
|
|
public static readonly BindableProperty RectangleBPProperty =
|
|
|
|
|
BindableProperty.Create ("RectangleBP", typeof(Rectangle), typeof(CompiledTypeConverter), default(Rectangle));
|
|
|
|
|
|
|
|
|
|
public Rectangle RectangleBP {
|
|
|
|
|
get { return (Rectangle)GetValue (RectangleBPProperty); }
|
|
|
|
|
set { SetValue (RectangleBPProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Rectangle RectangleP { get; set; }
|
|
|
|
|
|
2017-01-18 15:04:13 +03:00
|
|
|
|
[TypeConverter(typeof(ListStringTypeConverter))]
|
|
|
|
|
public IList<string> List { get; set; }
|
|
|
|
|
|
|
|
|
|
|
2016-09-26 23:29:47 +03:00
|
|
|
|
public CompiledTypeConverter ()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CompiledTypeConverter (bool useCompiledXaml)
|
|
|
|
|
{
|
|
|
|
|
//this stub will be replaced at compile time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class Tests
|
|
|
|
|
{
|
2016-12-05 15:40:12 +03:00
|
|
|
|
[TestCase(false)]
|
|
|
|
|
[TestCase(true)]
|
|
|
|
|
public void CompiledTypeConverterAreInvoked(bool useCompiledXaml)
|
2016-09-26 23:29:47 +03:00
|
|
|
|
{
|
2016-12-05 15:40:12 +03:00
|
|
|
|
var p = new CompiledTypeConverter(useCompiledXaml);
|
|
|
|
|
Assert.AreEqual(new Rectangle(0, 1, 2, 4), p.RectangleP);
|
|
|
|
|
Assert.AreEqual(new Rectangle(4, 8, 16, 32), p.RectangleBP);
|
|
|
|
|
Assert.AreEqual(Color.Pink, p.BackgroundColor);
|
|
|
|
|
Assert.AreEqual(LayoutOptions.EndAndExpand, p.label.GetValue(View.HorizontalOptionsProperty));
|
|
|
|
|
var xConstraint = RelativeLayout.GetXConstraint(p.label);
|
|
|
|
|
Assert.AreEqual(2, xConstraint.Compute(null));
|
2016-12-12 12:35:42 +03:00
|
|
|
|
Assert.AreEqual(new Thickness(2, 3), p.label.Margin);
|
2017-01-18 15:04:13 +03:00
|
|
|
|
Assert.AreEqual(2, p.List.Count);
|
|
|
|
|
Assert.AreEqual("Bar", p.List[1]);
|
2016-09-26 23:29:47 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-12 12:35:42 +03:00
|
|
|
|
}
|