File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
tests/Smdn.Net.MuninNode/Smdn.Net.MuninNode.DependencyInjection Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments