forked from SharpGenTools/SharpGenTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigPreprocessorTests.cs
More file actions
74 lines (69 loc) · 2.58 KB
/
Copy pathConfigPreprocessorTests.cs
File metadata and controls
74 lines (69 loc) · 2.58 KB
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
using System.IO;
using System.Xml.Linq;
using SharpGen.Config;
using Xunit;
namespace SharpGen.UnitTests
{
public class ConfigPreprocessorTests
{
[Fact]
public void IfDefIncludesChildrenWhenMacroDefined()
{
using (var stringReader = new StringReader(
Preprocessor.Preprocess(
$"<root xmlns:pre='{ConfigFile.XmlNamespace}'><pre:ifdef name='Defined'><child /></pre:ifdef></root>",
"Defined")))
{
var document = XDocument.Load(stringReader);
Assert.Single(document.Descendants("child"));
}
}
[Fact]
public void IfDefExcludesChildrenWhenMacroUndefined()
{
using (var stringReader = new StringReader(
Preprocessor.Preprocess(
$"<root xmlns:pre='{ConfigFile.XmlNamespace}'><pre:ifdef name='Undefined'><child /></pre:ifdef><child /></root>")))
{
var document = XDocument.Load(stringReader);
Assert.Single(document.Descendants("child"));
}
}
[Fact]
public void IfDefSupportsOrOperator()
{
using (var stringReader = new StringReader(
Preprocessor.Preprocess(
$"<root xmlns:pre='{ConfigFile.XmlNamespace}'><pre:ifdef name='Undefined|Defined'><child /></pre:ifdef></root>",
"Defined")))
{
var document = XDocument.Load(stringReader);
Assert.Single(document.Descendants("child"));
}
}
[Fact]
public void IfNDefExcludesChildrenWhenMacroDefined()
{
using (var stringReader = new StringReader(
Preprocessor.Preprocess(
$"<root xmlns:pre='{ConfigFile.XmlNamespace}'><pre:ifndef name='Defined'><child /></pre:ifndef></root>",
"Defined")))
{
var document = XDocument.Load(stringReader);
Assert.Empty(document.Descendants("child"));
}
}
[Fact]
public void IfNDefIncludesChildrenWhenMacroUndefined()
{
using (var stringReader = new StringReader(
Preprocessor.Preprocess(
$"<root xmlns:pre='{ConfigFile.XmlNamespace}'><pre:ifndef name='Undefined'><child /></pre:ifndef></root>"
)))
{
var document = XDocument.Load(stringReader);
Assert.Single(document.Descendants("child"));
}
}
}
}