diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2016-09-26 22:32:19 +0200 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-09-26 13:32:19 -0700 |
commit | 16295a31393ff8ea0011a9837f709cb063a245a1 (patch) | |
tree | aad3553adcb9c1902ec5e1253d4e48cf79a583eb /Xamarin.Forms.Core.UnitTests | |
parent | 55f066584c507ec92d5054fac4f3a35f54c05522 (diff) | |
download | xamarin-forms-16295a31393ff8ea0011a9837f709cb063a245a1.tar.gz xamarin-forms-16295a31393ff8ea0011a9837f709cb063a245a1.tar.bz2 xamarin-forms-16295a31393ff8ea0011a9837f709cb063a245a1.zip |
[C] specify type and default value for native bindings (#376)
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests')
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/NativeBindingTests.cs | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/NativeBindingTests.cs b/Xamarin.Forms.Core.UnitTests/NativeBindingTests.cs index 66577f63..c13608d8 100644 --- a/Xamarin.Forms.Core.UnitTests/NativeBindingTests.cs +++ b/Xamarin.Forms.Core.UnitTests/NativeBindingTests.cs @@ -13,6 +13,16 @@ namespace Xamarin.Forms.Core.UnitTests public int Bar { get; set; } public string Baz { get; set; } + string cantBeNull = ""; + public string CantBeNull { + get { return cantBeNull; } + set { + if (value == null) + throw new NullReferenceException(); + cantBeNull = value; + } + } + public void FireBazChanged() { BazChanged?.Invoke(this, new TappedEventArgs(null)); @@ -380,17 +390,6 @@ namespace Xamarin.Forms.Core.UnitTests } [Test] - public void ThrowsNeedsConverter() - { - var nativeView = new MockNativeView(); - Assert.AreEqual(null, nativeView.Foo); - Assert.AreEqual(0, nativeView.Bar); - var vm = new MockVMForNativeBinding(); - nativeView.SetBinding("SelectedColor", new Binding("CColor")); - Assert.Throws<ArgumentException>(() => nativeView.SetBindingContext(vm)); - } - - [Test] public void TestConverterDoesNotThrow() { var nativeView = new MockNativeView(); @@ -482,5 +481,16 @@ namespace Xamarin.Forms.Core.UnitTests nativeView.SetBindingContext(vm); Assert.AreEqual("foobar", vm.FFoo); } + + [Test] + public void DoNotApplyNull() + { + var native = new MockNativeView(); + Assert.NotNull(native.CantBeNull); + native.SetBinding("CantBeNull", new Binding("FFoo", BindingMode.TwoWay)); + Assert.NotNull(native.CantBeNull); + native.SetBindingContext(new { FFoo = "foo" }); + Assert.AreEqual("foo", native.CantBeNull); + } } }
\ No newline at end of file |