-
Notifications
You must be signed in to change notification settings - Fork 89
/
IconHelper_Should.cs
68 lines (61 loc) · 2.01 KB
/
IconHelper_Should.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
using System;
using System.ComponentModel;
using System.Windows.Media;
using FluentAssertions;
using Xunit;
namespace FontAwesome.Sharp.Tests.WPF;
// ReSharper disable once InconsistentNaming
public class IconHelper_Should
{
[Fact]
public void Convert_icon_enums_to_characters()
{
foreach (var icon in IconHelper.Icons)
{
var expected = char.ConvertFromUtf32((int)icon);
icon.ToChar().Should().Be(expected);
}
}
[WpfFact]
public void Lookup_fonts_for_glyphs()
{
foreach (var icon in IconHelper.Icons)
{
var font = IconHelper.FontFor(icon);
font.Should().NotBeNull($"should lookup font for '{icon}'");
font.Source.Should().Contain("FontAwesome.Sharp");
}
}
[WpfFact]
public void Generate_imageSources_for_icon_chars()
{
foreach (var icon in IconHelper.Icons)
{
const int size = 16;
const int delta = +2;
var imageSource = icon.ToImageSource(Brushes.Black, size);
imageSource.Should().NotBeNull($"an image should be generated for '{icon}'");
imageSource.Should().BeOfType<DrawingImage>();
Math.Max(imageSource.Width, imageSource.Height).Should().BeLessOrEqualTo(size + delta,
$"{icon} size should be less than {size}+{delta}.");
}
}
[WpfFact]
[Description("Some icons are not contained in any ttf-webfont!")]
public void Skip_orphaned_icons()
{
foreach (var icon in IconHelper.Orphans)
{
icon.ToImageSource().Should().BeNull($"{icon} is assumed to be an orphan.");
}
}
[WpfTheory]
[InlineData(IconChar.Save)]
public void Support_Font_Styles(IconChar icon)
{
var bitmap = icon.ToImageSource(IconFont.Auto, IconHelper.DefaultBrush, 48);
bitmap.Should().NotBeEmpty();
bitmap = icon.ToImageSource(IconFont.Regular, IconHelper.DefaultBrush, 48);
bitmap.Should().NotBeEmpty();
}
}