summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-03-02 23:28:37 +0100
committerGitHub <noreply@github.com>2017-03-02 23:28:37 +0100
commitd2708bbadd0bf09c2542e354683c0fd1bbc84707 (patch)
tree6f267d261bbc60cfa9a723a9ade669e061f17aa8 /Xamarin.Forms.Core.UnitTests
parenta03c8f32d20a61a1a553b7db0e2f978c44a4ca84 (diff)
downloadxamarin-forms-d2708bbadd0bf09c2542e354683c0fd1bbc84707.tar.gz
xamarin-forms-d2708bbadd0bf09c2542e354683c0fd1bbc84707.tar.bz2
xamarin-forms-d2708bbadd0bf09c2542e354683c0fd1bbc84707.zip
[Xaml] Fallback to App.Current for DynResources (Previewer) (#793)
* [Xaml] Fallback to App.Current for DynResources (Previewer) * [C] avoid NRE and ensure setting the style
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests')
-rw-r--r--Xamarin.Forms.Core.UnitTests/DynamicResourceTests.cs22
1 files changed, 21 insertions, 1 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/DynamicResourceTests.cs b/Xamarin.Forms.Core.UnitTests/DynamicResourceTests.cs
index faea9963..25ae3290 100644
--- a/Xamarin.Forms.Core.UnitTests/DynamicResourceTests.cs
+++ b/Xamarin.Forms.Core.UnitTests/DynamicResourceTests.cs
@@ -10,6 +10,13 @@ namespace Xamarin.Forms.Core.UnitTests
{
base.Setup ();
Device.PlatformServices = new MockPlatformServices ();
+ Application.Current = new MockApplication();
+ }
+
+ [TearDown]
+ public override void TearDown()
+ {
+ Application.Current = null;
}
[Test]
@@ -143,11 +150,24 @@ namespace Xamarin.Forms.Core.UnitTests
label.SetDynamicResource (Label.TextProperty, "foo");
label.Resources = new ResourceDictionary { {"foo","FOO"}};
- Assert.AreEqual ("FOO", label.Text);
+ Assume.That(label.Text, Is.EqualTo("FOO"));
label.Resources ["foo"] = "BAR";
Assert.AreEqual ("BAR", label.Text);
}
+
+ [Test]
+ public void FallbackToApplicationCurrent()
+ {
+ Application.Current.Resources = new ResourceDictionary { { "foo", "FOO" } };
+
+ var label = new Label();
+ label.BindingContext = new MockViewModel();
+ label.SetBinding(Label.TextProperty, "Text", BindingMode.TwoWay);
+ label.SetDynamicResource(Label.TextProperty, "foo");
+
+ Assert.That(label.Text, Is.EqualTo("FOO"));
+ }
}
} \ No newline at end of file