summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1250.xaml.cs
blob: 8f4cdb7d16b4805d64de5874774444d573a90c2a (plain)
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
45
46
47
48
49
using System;
using System.Collections.Generic;

using Xamarin.Forms;

using NUnit.Framework;

namespace Xamarin.Forms.Xaml.UnitTests
{
	public class Issue1250AspectRatioContainer : ContentView
	{
		protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
		{
			return new SizeRequest(new Size(widthConstraint, widthConstraint * AspectRatio));
		}

		public double AspectRatio { get; set; }
	}

	public partial class Issue1250 : ContentPage
	{
		public Issue1250 ()
		{
			InitializeComponent ();
		}

		public Issue1250 (bool useCompiledXaml)
		{
			//this stub will be replaced at compile time
		}

		[TestFixture]
		public class Tests
		{
			[TestCase (false)]
			[TestCase (true)]
			public void AddCustomElementInCollection (bool useCompiledXaml)
			{
				var page = new Issue1250 (useCompiledXaml);
				var stack = page.stack;

				Assert.AreEqual (3, stack.Children.Count);
				Assert.That (stack.Children [0], Is.TypeOf<Label> ());
				Assert.That (stack.Children [1], Is.TypeOf<Issue1250AspectRatioContainer> ());
				Assert.That (stack.Children [2], Is.TypeOf<Label> ());
			}
		}
	}
}