1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
using NUnit.Framework;
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; }
public CompiledTypeConverter ()
{
InitializeComponent ();
}
public CompiledTypeConverter (bool useCompiledXaml)
{
//this stub will be replaced at compile time
}
[TestFixture]
public class Tests
{
[TestCase(false)]
[TestCase(true)]
public void CompiledTypeConverterAreInvoked(bool useCompiledXaml)
{
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));
}
}
}
}
|