summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-09-23 09:01:22 +0200
committerJason Smith <jason.smith@xamarin.com>2016-09-23 00:01:22 -0700
commita5183bed8d38db411549733934b53380b93773b5 (patch)
tree51953e228a71cb59600c8c5ab001a959ee811a27 /Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs
parent1076e735697d393c7b10654f8dc7d9a91c7c13e1 (diff)
downloadxamarin-forms-a5183bed8d38db411549733934b53380b93773b5.tar.gz
xamarin-forms-a5183bed8d38db411549733934b53380b93773b5.tar.bz2
xamarin-forms-a5183bed8d38db411549733934b53380b93773b5.zip
[XamlC] Implement IValueProvider.PropertyType (#345)
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs72
1 files changed, 66 insertions, 6 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs
index 2c2c6482..6d9dad6e 100644
--- a/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs
@@ -22,6 +22,18 @@ namespace Xamarin.Forms.Xaml.UnitTests
[TestFixture]
public class Tests
{
+ [SetUp]
+ public void Setup()
+ {
+ Device.PlatformServices = new MockPlatformServices();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Device.PlatformServices = null;
+ }
+
[TestCase (false)]
[TestCase (true)]
public void BoolToVisibility (bool useCompiledXaml)
@@ -34,13 +46,61 @@ namespace Xamarin.Forms.Xaml.UnitTests
layout = new OnPlatform (useCompiledXaml);
Assert.AreEqual (false, layout.label0.IsVisible);
}
- }
- public void T ()
- {
- var onplat = new OnPlatform<bool> ();
- var label = new Label ();
- label.IsVisible = onplat;
+ [TestCase(false)]
+ [TestCase(true)]
+ public void DoubleToWidth(bool useCompiledXaml)
+ {
+ Device.OS = TargetPlatform.iOS;
+ var layout = new OnPlatform(useCompiledXaml);
+ Assert.AreEqual(20, layout.label0.WidthRequest);
+
+ Device.OS = TargetPlatform.Android;
+ layout = new OnPlatform(useCompiledXaml);
+ Assert.AreEqual(30, layout.label0.WidthRequest);
+ }
+
+ [TestCase(false)]
+ [TestCase(true)]
+ public void StringToText(bool useCompiledXaml)
+ {
+ Device.OS = TargetPlatform.iOS;
+ var layout = new OnPlatform(useCompiledXaml);
+ Assert.AreEqual("Foo", layout.label0.Text);
+
+ Device.OS = TargetPlatform.Android;
+ layout = new OnPlatform(useCompiledXaml);
+ Assert.AreEqual("Bar", layout.label0.Text);
+ }
+
+ [TestCase(false)]
+ [TestCase(true)]
+ public void OnPlatformAsResource(bool useCompiledXaml)
+ {
+ var layout = new OnPlatform(useCompiledXaml);
+ var onplat = layout.Resources ["fontAttributes"] as OnPlatform<FontAttributes>;
+ Assert.NotNull(onplat);
+ Assert.AreEqual(FontAttributes.Bold, onplat.iOS);
+
+ Assert.AreEqual(FontAttributes.Italic, onplat.Android);
+ }
+
+ [TestCase(false)]
+ [TestCase(true)]
+ public void OnPlatformAsResourceAreApplied(bool useCompiledXaml)
+ {
+ Device.OS = TargetPlatform.iOS;
+ var layout = new OnPlatform(useCompiledXaml);
+ var onidiom = layout.Resources ["fontSize"] as OnIdiom<double>;
+ Assert.NotNull(onidiom);
+ Assert.That(onidiom.Phone, Is.TypeOf<double>());
+ Assert.AreEqual(20, onidiom.Phone);
+ Assert.AreEqual(FontAttributes.Bold, layout.label0.FontAttributes);
+
+ Device.OS = TargetPlatform.Android;
+ layout = new OnPlatform(useCompiledXaml);
+ Assert.AreEqual(FontAttributes.Italic, layout.label0.FontAttributes);
+ }
}
}
} \ No newline at end of file