summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1501.cs
blob: d4a5e761da3c6b4078affedc7c1731fba06d8472 (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
using System;
using NUnit.Framework;

namespace Xamarin.Forms.Xaml.UnitTests
{
	public class BoxView1501 : BoxView 
	{
		public bool Fired { get; set;}

		public void OnBoxViewTapped (object sender, EventArgs e)
		{
			Fired = true;
		}
	}

	[TestFixture]
	public class Issue1501
	{
		[Test]
		public void ConnectEventsInGestureRecognizers ()
		{
			var xaml = @"
				<BoxView 
					xmlns=""http://xamarin.com/schemas/2014/forms""
					xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
					x:Class=""Xamarin.Forms.Xaml.UnitTests.BoxView1501"" >
				    <BoxView.GestureRecognizers>
				      <TapGestureRecognizer Tapped=""OnBoxViewTapped"" />
				    </BoxView.GestureRecognizers>
				</BoxView>";

			BoxView1501 layout = null;
			Assert.DoesNotThrow (() => {layout = new BoxView1501 ().LoadFromXaml (xaml);});

			Assert.False (layout.Fired);
			var tgr = layout.GestureRecognizers [0] as TapGestureRecognizer;
			tgr.SendTapped (layout);
			Assert.True (layout.Fired);
		}
	}
}