maui-linux/Xamarin.Forms.Xaml.UnitTests/FactoryMethodMissingCtor.xa...

32 строки
949 B
C#

using System;
using NUnit.Framework;
using Xamarin.Forms.Core.UnitTests;
namespace Xamarin.Forms.Xaml.UnitTests
{
[XamlCompilation(XamlCompilationOptions.Skip)]
public partial class FactoryMethodMissingCtor : MockView
{
public FactoryMethodMissingCtor() => InitializeComponent();
public FactoryMethodMissingCtor(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}
[TestFixture]
public class Tests
{
[SetUp] public void Setup() => Device.PlatformServices = new MockPlatformServices();
[TearDown] public void TearDown() => Device.PlatformServices = null;
[Test]
public void Throw([Values(false, true)]bool useCompiledXaml)
{
if (useCompiledXaml)
Assert.Throws(new XamlParseExceptionConstraint(7, 4), () => MockCompiler.Compile(typeof(FactoryMethodMissingCtor)));
else
Assert.Throws<MissingMethodException>(() => new FactoryMethodMissingCtor(useCompiledXaml));
}
}
}
}