-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
FontImageExtension.xaml.cs
72 lines (59 loc) · 1.75 KB
/
FontImageExtension.xaml.cs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
using NUnit.Framework;
using Xamarin.Forms.Core.UnitTests;
namespace Xamarin.Forms.Xaml.UnitTests
{
public partial class FontImageExtension : TabBar
{
public FontImageExtension() => InitializeComponent();
public FontImageExtension(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}
public static string FontFamily => "MyFontFamily";
public static string Glyph => "MyGlyph";
public static Color Color => Color.Black;
public static double Size = 50d;
[TestFixture]
class Tests
{
[SetUp] public void Setup() => Device.PlatformServices = new MockPlatformServices();
[TearDown] public void TearDown() => Device.PlatformServices = null;
[TestCase(true), TestCase(false)]
public void FontImageExtension_Positive(bool useCompiledXaml)
{
var layout = new FontImageExtension(useCompiledXaml);
var tabs = layout.AllChildren;
int i = 0;
foreach(var tab in tabs)
{
Tab myTab = (Tab)tab;
if (myTab == null)
continue;
Assert.That(myTab.Icon, Is.TypeOf<FontImageSource>());
var fontImage = (FontImageSource)myTab.Icon;
Assert.AreEqual(FontFamily, fontImage.FontFamily);
Assert.AreEqual(Glyph, fontImage.Glyph);
if(i == 3)
Assert.AreEqual(30d, fontImage.Size);
else
Assert.AreEqual(Size, fontImage.Size);
Assert.AreEqual(Color, fontImage.Color);
i++;
}
}
[TestCase(true), TestCase(false)]
public void FontImageExtension_Negative(bool useCompiledXaml)
{
var layout = new FontImageExtension(useCompiledXaml);
var tabs = layout.AllChildren;
foreach (var tab in tabs)
{
Tab myTab = (Tab)tab;
if (myTab == null)
continue;
Assert.That(myTab.Icon, Is.Not.TypeOf<ImageSource>());
}
}
}
}
}