зеркало из https://github.com/DeGsoft/maui-linux.git
43 строки
1.2 KiB
C#
43 строки
1.2 KiB
C#
using System;
|
|
using System.Windows.Input;
|
|
using NUnit.Framework;
|
|
using Xamarin.Forms.Core.UnitTests;
|
|
|
|
namespace Xamarin.Forms.Xaml.UnitTests
|
|
{
|
|
#pragma warning disable 0618 //retaining legacy call to obsolete code
|
|
|
|
[TestFixture]
|
|
public class XamlLoaderCreateTests
|
|
{
|
|
[Test]
|
|
public void CreateFromXaml ()
|
|
{
|
|
var xaml = @"
|
|
<ContentView xmlns=""http://xamarin.com/schemas/2014/forms""
|
|
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
|
|
x:Class=""Xamarin.Forms.Xaml.UnitTests.FOO"">
|
|
<Label Text=""Foo"" x:Name=""label""/>
|
|
</ContentView>";
|
|
|
|
var view = XamlLoader.Create (xaml);
|
|
Assert.That (view, Is.TypeOf<ContentView> ());
|
|
Assert.AreEqual ("Foo", ((Label)((ContentView)view).Content).Text);
|
|
}
|
|
|
|
[Test]
|
|
public void CreateFromXamlDoesntFailOnMissingEventHandler ()
|
|
{
|
|
var xaml = @"
|
|
<Button xmlns=""http://xamarin.com/schemas/2014/forms""
|
|
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
|
|
Clicked=""handleClick"">
|
|
</Button>";
|
|
|
|
Button button = null;
|
|
Assert.DoesNotThrow (() => button = XamlLoader.Create (xaml, true) as Button);
|
|
Assert.NotNull (button);
|
|
}
|
|
}
|
|
#pragma warning restore 0618
|
|
} |