using NUnit.Framework;
using System;
using Xamarin.Forms.Core.UnitTests;
namespace Xamarin.Forms.Xaml.UnitTests
{
[TestFixture]
public class OnPlatformTests : BaseTestFixture
{
[Test]
public void ApplyToProperty ()
{
var xaml = @"
";
var layout = new ContentPage ().LoadFromXaml (xaml);
Assert.NotNull (layout.Content);
}
[Test]
public void UseTypeConverters ()
{
var xaml = @"
0, 20, 0, 0
0, 0, 10, 0
0, 20, 0, 20
";
ContentPage layout;
Device.OS = TargetPlatform.iOS;
layout = new ContentPage ().LoadFromXaml (xaml);
Assert.AreEqual (new Thickness (0, 20, 0, 0), layout.Padding);
Device.OS = TargetPlatform.Android;
layout = new ContentPage ().LoadFromXaml (xaml);
Assert.AreEqual (new Thickness (0, 0, 10, 0), layout.Padding);
Device.OS = TargetPlatform.WinPhone;
layout = new ContentPage ().LoadFromXaml (xaml);
Assert.AreEqual (new Thickness (0, 20, 0, 20), layout.Padding);
}
[Test]
//Issue 1480
public void TypeConverterAndDerivedTypes ()
{
var xaml = @"
icon_twitter.png
icon_twitter.png
Images/icon_twitter.png
";
Image image;
Device.OS = TargetPlatform.iOS;
image = new Image ().LoadFromXaml (xaml);
Assert.AreEqual ("icon_twitter.png", (image.Source as FileImageSource).File);
}
}
[TestFixture]
public class OnIdiomTests : BaseTestFixture
{
[Test]
public void StackLayoutOrientation ()
{
var xaml = @"
Vertical
Horizontal
";
Device.Idiom = TargetIdiom.Phone;
var layout = new StackLayout ().LoadFromXaml (xaml);
Assert.AreEqual (StackOrientation.Vertical, layout.Orientation);
Device.Idiom = TargetIdiom.Tablet;
layout = new StackLayout ().LoadFromXaml (xaml);
Assert.AreEqual (StackOrientation.Horizontal, layout.Orientation);
}
}
}