Esempio n. 1
0
            public void OnPlatformAsResource(bool useCompiledXaml)
            {
                var layout = new OnPlatform(useCompiledXaml);
                var onplat = layout.Resources["fontAttributes"] as OnPlatform <FontAttributes>;

                Assert.NotNull(onplat);
                mockDeviceInfo.Platform = DevicePlatform.iOS;
                Assert.AreEqual(FontAttributes.Bold, (FontAttributes)onplat);
                mockDeviceInfo.Platform = DevicePlatform.Android;
                Assert.AreEqual(FontAttributes.Italic, (FontAttributes)onplat);
            }
Esempio n. 2
0
            public void StringToText(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.iOS;
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual("Foo", layout.label0.Text);

                mockDeviceInfo.Platform = DevicePlatform.Android;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual("Bar", layout.label0.Text);
            }
Esempio n. 3
0
            public void DoubleToWidth(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.iOS;
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(20, layout.label0.WidthRequest);

                mockDeviceInfo.Platform = DevicePlatform.Android;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(30, layout.label0.WidthRequest);
            }
Esempio n. 4
0
            public void BoolToVisibility(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.iOS;
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(true, layout.label0.IsVisible);

                mockDeviceInfo.Platform = DevicePlatform.Android;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(false, layout.label0.IsVisible);
            }
Esempio n. 5
0
            public void OnPlatformAsResourceAreApplied(bool useCompiledXaml)
            {
                ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.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);

                ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(FontAttributes.Italic, layout.label0.FontAttributes);
            }
Esempio n. 6
0
            public void OnPlatform2Syntax(bool useCompiledXaml)
            {
                ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android;
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(42, layout.label0.HeightRequest);

                ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(21, layout.label0.HeightRequest);


                ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = "FooBar";
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(42, layout.label0.HeightRequest);
            }
Esempio n. 7
0
            public void OnPlatform2Syntax(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.Android;
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(42, layout.label0.HeightRequest);

                mockDeviceInfo.Platform = DevicePlatform.iOS;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(21, layout.label0.HeightRequest);


                mockDeviceInfo.Platform = DevicePlatform.Create("FooBar");
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(42, layout.label0.HeightRequest);
            }