зеркало из https://github.com/DeGsoft/maui-linux.git
62 строки
1.3 KiB
C#
62 строки
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using Xamarin.Forms;
|
|
using Xamarin.Forms.Core.UnitTests;
|
|
|
|
namespace Xamarin.Forms.Xaml.UnitTests
|
|
{
|
|
[AcceptEmptyServiceProvider]
|
|
public class FooExtension : IMarkupExtension<IServiceProvider>
|
|
{
|
|
public IServiceProvider ProvideValue(IServiceProvider serviceProvider)
|
|
{
|
|
return serviceProvider;
|
|
}
|
|
|
|
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
|
|
{
|
|
return (this as IMarkupExtension<IServiceProvider>).ProvideValue(serviceProvider);
|
|
}
|
|
}
|
|
|
|
public partial class AcceptEmptyServiceProvider : ContentPage
|
|
{
|
|
public AcceptEmptyServiceProvider()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public AcceptEmptyServiceProvider(bool useCompiledXaml)
|
|
{
|
|
//this stub will be replaced at compile time
|
|
}
|
|
|
|
public IServiceProvider ServiceProvider { get; set; }
|
|
|
|
[TestFixture]
|
|
class Tests
|
|
{
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
Device.PlatformServices = new MockPlatformServices();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
Device.PlatformServices = null;
|
|
}
|
|
|
|
[TestCase(true)]
|
|
[TestCase(false)]
|
|
public void ServiceProviderIsNullOnAttributedExtensions(bool useCompiledXaml)
|
|
{
|
|
var p = new AcceptEmptyServiceProvider(useCompiledXaml);
|
|
Assert.IsNull(p.ServiceProvider);
|
|
}
|
|
}
|
|
}
|
|
}
|