using System; using NUnit.Framework; namespace Xamarin.Forms.Core.UnitTests { [TestFixture] public class BindableObjectExtensionTests : BaseTestFixture { [Test] public void SetBindingNull() { Assert.That (() => BindableObjectExtensions.SetBinding (null, MockBindable.TextProperty, "Name"), Throws.InstanceOf()); Assert.That (() => BindableObjectExtensions.SetBinding (new MockBindable(), null, "Name"), Throws.InstanceOf()); Assert.That (() => BindableObjectExtensions.SetBinding (new MockBindable(), MockBindable.TextProperty, null), Throws.InstanceOf()); Assert.That (() => BindableObjectExtensions.SetBinding (null, MockBindable.TextProperty, vm => vm.Text), Throws.InstanceOf()); Assert.That (() => BindableObjectExtensions.SetBinding (new MockBindable(), null, vm => vm.Text), Throws.InstanceOf()); Assert.That (() => BindableObjectExtensions.SetBinding (new MockBindable(), MockBindable.TextProperty, null), Throws.InstanceOf()); } [Test] public void Issue2643() { Label labelTempoDiStampa = new Label(); labelTempoDiStampa.BindingContext = new { Name = "1", Company = "Xamarin" }; labelTempoDiStampa.SetBinding (Label.TextProperty, "Name", stringFormat: "Hi: {0}"); Assert.That (labelTempoDiStampa.Text, Is.EqualTo ("Hi: 1")); } class Bz27229ViewModel { public object Member { get; private set; } public Bz27229ViewModel () { Member = new Generic