-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGraphitePathTest.cs
64 lines (60 loc) · 2.55 KB
/
GraphitePathTest.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
using ahd.Graphite.Base;
using Xunit;
namespace ahd.Graphite.Test
{
public class GraphitePathTest
{
[Fact]
public void GraphitePath()
{
var path = new GraphitePath("metric");
Assert.Equal("metric", path.Name);
Assert.Equal("metric", path.ToString());
}
[Fact]
public void CombineNameTest()
{
var path = new GraphitePath("metric");
Assert.Equal("metric", path.ToString());
path = path.Dot("used");
Assert.Equal("metric.used", path.ToString());
path = path.Wildcard();
Assert.Equal("metric.used*", path.ToString());
path = path.Wildcard();
Assert.Equal("metric.used*", path.ToString());
path = path.DotWildcard();
Assert.Equal("metric.used*.*", path.ToString());
path = path.Range('a', 'z');
Assert.Equal("metric.used*.*[a-z]", path.ToString());
path = path.Range('0', '9');
Assert.Equal("metric.used*.*[a-z0-9]", path.ToString());
path = path.DotRange('0', '9');
Assert.Equal("metric.used*.*[a-z0-9].[0-9]", path.ToString());
path = path.Chars('a', 'd', 'f');
Assert.Equal("metric.used*.*[a-z0-9].[0-9][adf]", path.ToString());
path = path.Chars('q');
Assert.Equal("metric.used*.*[a-z0-9].[0-9][adfq]", path.ToString());
path = path.DotChars('w');
Assert.Equal("metric.used*.*[a-z0-9].[0-9][adfq].[w]", path.ToString());
path = path.Values("asdf");
Assert.Equal("metric.used*.*[a-z0-9].[0-9][adfq].[w]{asdf}", path.ToString());
path = path.Values("qwertz");
Assert.Equal("metric.used*.*[a-z0-9].[0-9][adfq].[w]{asdf,qwertz}", path.ToString());
path = path.DotValues("01","02","03");
Assert.Equal("metric.used*.*[a-z0-9].[0-9][adfq].[w]{asdf,qwertz}.{01,02,03}", path.ToString());
}
[Fact]
public void AlternatingTest()
{
var path = new GraphitePath("dummy");
path = path.Chars('a', 'b', 'd').Values("a","v","b").Chars('z','y','x');
Assert.Equal("dummy[abd]{a,v,b}[zyx]", path.ToString());
}
[Fact]
public void WildcardTest()
{
var metric = new GraphitePath("usage").Dot("unittest").DotWildcard().Dot("count");
Assert.Equal("usage.unittest.*.count", metric.ToString());
}
}
}