summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests/Issues/Bz34037.xaml.cs
blob: ee300cb019020df0c6640bff642004de551203b3 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;

using Xamarin.Forms;
using NUnit.Framework;

namespace Xamarin.Forms.Xaml.UnitTests
{
	public class Bz34037Converter0 : IValueConverter, IMarkupExtension
	{
		public static int Invoked { get; set; }
		public static object Parameter { get; set; }
		public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			Invoked++;
			Parameter = parameter;
			return true;
		}

		public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new NotImplementedException ();
		}

		public object ProvideValue (IServiceProvider serviceProvider)
		{
			return new Bz34037Converter0 ();
		}
	}

	public class Bz34037Converter1 : IValueConverter, IMarkupExtension
	{
		public static int Invoked { get; set; }
		public static object Parameter { get; set; }
		public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			Invoked++;
			Parameter = parameter;
			return true;
		}

		public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new NotImplementedException ();
		}

		public object ProvideValue (IServiceProvider serviceProvider)
		{
			return new Bz34037Converter1 ();
		}
	}

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

		public string Property {
			get { return "FooBar"; }
		}

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

		[TestFixture]
		class Tests
		{
			[SetUp]
			public void Setup ()
			{
				Bz34037Converter0.Invoked = 0;
				Bz34037Converter1.Invoked = 0;
			}

			[TestCase(true)]
			[TestCase(false)]
			public void ConverterParameterOrderDoesNotMatters (bool useCompiledXaml)
			{
				var layout = new Bz34037 (useCompiledXaml);
				Assert.AreEqual (2, Bz34037Converter0.Invoked);
//				Assert.AreEqual (2, Bz34037Converter1.Invoked);
				Assert.AreEqual (typeof(string), Bz34037Converter0.Parameter);
//				Assert.AreEqual (typeof(string), Bz34037Converter1.Parameter);
			}
		}
	}
}