forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 5
/
FontDescriptionTests.cs
100 lines (88 loc) · 4.19 KB
/
FontDescriptionTests.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using NUnit.Framework;
namespace MonoGame.Tests.ContentPipeline
{
class FontDescriptionTests
{
[Test]
public void ValidateMembers()
{
{
var font = new FontDescription("FontName", 12.34f, 5.67f);
Assert.NotNull(font.Characters);
Assert.AreEqual(0, font.Characters.Count);
Assert.IsNull(font.DefaultCharacter);
Assert.AreEqual("FontName", font.FontName);
Assert.AreEqual(12.34f, font.Size);
Assert.AreEqual(5.67f, font.Spacing);
Assert.AreEqual(FontDescriptionStyle.Regular, font.Style);
Assert.AreEqual(false, font.UseKerning);
Assert.IsNull(font.Identity);
Assert.IsNull(font.Name);
Assert.NotNull(font.OpaqueData);
Assert.AreEqual(0, font.OpaqueData.Count);
}
{
var font = new FontDescription("FontName", 12.34f, 5.67f, FontDescriptionStyle.Italic);
Assert.NotNull(font.Characters);
Assert.AreEqual(0, font.Characters.Count);
Assert.IsNull(font.DefaultCharacter);
Assert.AreEqual("FontName", font.FontName);
Assert.AreEqual(12.34f, font.Size);
Assert.AreEqual(5.67f, font.Spacing);
Assert.AreEqual(FontDescriptionStyle.Italic, font.Style);
Assert.AreEqual(false, font.UseKerning);
Assert.IsNull(font.Identity);
Assert.IsNull(font.Name);
Assert.NotNull(font.OpaqueData);
Assert.AreEqual(0, font.OpaqueData.Count);
}
{
var font = new FontDescription("FontName", 12.34f, 5.67f, FontDescriptionStyle.Bold, true);
Assert.NotNull(font.Characters);
Assert.AreEqual(0, font.Characters.Count);
Assert.IsNull(font.DefaultCharacter);
Assert.AreEqual("FontName", font.FontName);
Assert.AreEqual(12.34f, font.Size);
Assert.AreEqual(5.67f, font.Spacing);
Assert.AreEqual(FontDescriptionStyle.Bold, font.Style);
Assert.AreEqual(true, font.UseKerning);
Assert.IsNull(font.Identity);
Assert.IsNull(font.Name);
Assert.NotNull(font.OpaqueData);
Assert.AreEqual(0, font.OpaqueData.Count);
}
Assert.Throws<ArgumentNullException>(() => new FontDescription(null, 1, 1));
Assert.Throws<ArgumentNullException>(() => new FontDescription("", 1, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => new FontDescription("Aye", 0, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => new FontDescription("Aye", -1, 1));
{
var font = new FontDescription("Bee", 1, 1);
font.DefaultCharacter = 'A';
Assert.AreEqual('A', font.DefaultCharacter);
font.DefaultCharacter = null;
Assert.IsNull(font.DefaultCharacter);
font.FontName = "See";
Assert.AreEqual("See", font.FontName);
Assert.Throws<ArgumentNullException>(() => font.FontName = null);
Assert.Throws<ArgumentNullException>(() => font.FontName = "");
font.Size = 2;
Assert.AreEqual(2, font.Size);
Assert.Throws<ArgumentOutOfRangeException>(() => font.Size = 0);
Assert.Throws<ArgumentOutOfRangeException>(() => font.Size = -1);
font.Spacing = 2;
Assert.AreEqual(2, font.Spacing);
font.Spacing = 0;
Assert.AreEqual(0, font.Spacing);
font.Spacing = -2;
Assert.AreEqual(-2, font.Spacing);
font.Style = FontDescriptionStyle.Italic;
Assert.AreEqual(FontDescriptionStyle.Italic, font.Style);
font.UseKerning = true;
Assert.AreEqual(true, font.UseKerning);
}
}
}
}