blob: cd7913ce92349b52117b35b1d29058b8cbf2d412 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Xamarin.Forms;
namespace Xamarin.Forms.Xaml.UnitTests
{
public partial class XamlLoaderGetXamlForTypeTests : ContentPage
{
public XamlLoaderGetXamlForTypeTests()
{
InitializeComponent();
}
public XamlLoaderGetXamlForTypeTests(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}
[TestFixture]
public class Tests
{
[SetUp]
public void SetUp()
{
#pragma warning disable 0618
Xamarin.Forms.Xaml.Internals.XamlLoader.XamlFileProvider = null;
#pragma warning restore 0618
}
[TestCase(false)]
[TestCase(true)]
public void XamlContentIsReplaced(bool useCompiledXaml)
{
var layout = new XamlLoaderGetXamlForTypeTests(useCompiledXaml);
Assert.That(layout.Content, Is.TypeOf<Button>());
#pragma warning disable 0618
Xamarin.Forms.Xaml.Internals.XamlLoader.XamlFileProvider = (t) => {
#pragma warning restore 0618
if (t == typeof(XamlLoaderGetXamlForTypeTests))
return @"
<ContentPage xmlns=""http://xamarin.com/schemas/2014/forms""
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
x:Class=""Xamarin.Forms.Xaml.UnitTests.XamlLoaderGetXamlForTypeTests"">
<Label x:Name=""Label""/>
</ContentPage>";
return null;
};
layout = new XamlLoaderGetXamlForTypeTests(useCompiledXaml);
Assert.That(layout.Content, Is.TypeOf<Label>());
}
}
}
}
|