using System; using NUnit.Framework; using System.Collections.ObjectModel; using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { public class SeverityColorConverter : IValueConverter { public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { count++; return Color.Blue; } public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException (); } public static int count=0; } public class InvertBoolenConverter : IValueConverter { public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { count++; if (value is bool) { return !(bool)value; } return value; } public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException (); } public static int count=0; } public class Item { public bool IsLocked { get; set; } } [TestFixture] public class Issue1549 { [SetUp] public void Setup () { SeverityColorConverter.count = 0; InvertBoolenConverter.count = 0; Device.PlatformServices = new MockPlatformServices(); } [TearDown] public void TearDown() { Device.PlatformServices = null; } [Test] public void ConverterIsInvoked () { var xaml = @" "; var layout = new ContentPage ().LoadFromXaml (xaml); layout.BindingContext = new {Value = "Foo", Severity = "Bar"}; var label = layout.FindByName