Skip to content

Commit b96210c

Browse files
committed
add test cases
1 parent 04aea47 commit b96210c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/Smdn.Net.MuninNode/Smdn.Net.MuninNode.DependencyInjection/IMuninServiceBuilderExtensions.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,42 @@ public void AddNode_ArgumentNull()
2828
});
2929
}
3030

31+
[TestCase("_")]
32+
[TestCase("munin-node.localhost")]
33+
public void AddNode_IMuninNodeBuilderServiceKey(string hostname)
34+
{
35+
var services = new ServiceCollection();
36+
37+
services.AddMunin(configure: builder => {
38+
var nodeBuilder = builder.AddNode(configure: options => options.HostName = hostname);
39+
40+
Assert.That(nodeBuilder.ServiceKey, Is.EqualTo(hostname));
41+
});
42+
}
43+
44+
[Test]
45+
public void AddNode_PostConfigure_MuninNodeOptions()
46+
{
47+
const string HostNameForServiceKeyAndOptionName = "munin-node.localhost";
48+
const string HostNameForPostConfigure = "postconfigure.munin-node.localhost";
49+
50+
var services = new ServiceCollection();
51+
52+
services.AddMunin(configure: builder => {
53+
builder.AddNode(configure: options => options.HostName = HostNameForServiceKeyAndOptionName);
54+
});
55+
56+
services.PostConfigure<MuninNodeOptions>(
57+
name: HostNameForServiceKeyAndOptionName,
58+
configureOptions: options => options.HostName = HostNameForPostConfigure
59+
);
60+
61+
var serviceProvider = services.BuildServiceProvider();
62+
var node = serviceProvider.GetRequiredService<IMuninNode>();
63+
64+
Assert.That(node.HostName, Is.EqualTo(HostNameForPostConfigure));
65+
}
66+
3167
[Test]
3268
public void AddNode_GetService()
3369
{

0 commit comments

Comments
 (0)