Skip to content

Commit 4b71eeb

Browse files
committed
add MultigraphPlugin
1 parent 541eba2 commit 4b71eeb

File tree

4 files changed

+74
-22
lines changed

4 files changed

+74
-22
lines changed

examples/Smdn.Net.MuninNode/multigraph/MultigraphPlugin.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
// SPDX-License-Identifier: MIT
3+
using System;
4+
using System.Collections.Generic;
5+
6+
namespace Smdn.Net.MuninPlugin;
7+
8+
public class MultigraphPlugin : IMultigraphPlugin {
9+
/// <inheritdoc cref="IPlugin.Name"/>
10+
public string Name { get; }
11+
12+
/// <inheritdoc cref="IMultigraphPlugin.Plugins"/>
13+
public IReadOnlyCollection<IPlugin> Plugins { get; }
14+
15+
/// <inheritdoc cref="IPlugin.DataSource"/>
16+
public IPluginDataSource DataSource => throw new NotSupportedException();
17+
18+
/// <inheritdoc cref="IPlugin.GraphAttributes"/>
19+
public IPluginGraphAttributes GraphAttributes => throw new NotSupportedException();
20+
21+
/// <inheritdoc cref="IPlugin.SessionCallback"/>
22+
public INodeSessionCallback? SessionCallback => throw new NotSupportedException();
23+
24+
public MultigraphPlugin(string name, IReadOnlyCollection<IPlugin> plugins)
25+
{
26+
ArgumentExceptionShim.ThrowIfNullOrWhiteSpace(name, nameof(name));
27+
28+
Name = name;
29+
Plugins = plugins ?? throw new ArgumentNullException(nameof(plugins));
30+
}
31+
}

tests/Smdn.Net.MuninNode/Smdn.Net.MuninNode.Protocol/MuninProtocolHandler.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ namespace Smdn.Net.MuninNode.Protocol;
1919

2020
[TestFixture]
2121
public partial class MuninProtocolHandlerTests {
22-
private class MultigraphPlugin(string name, IReadOnlyCollection<IPlugin> plugins) : IMultigraphPlugin {
23-
public string Name { get; } = name;
24-
public IReadOnlyCollection<IPlugin> Plugins { get; } = plugins;
25-
public IPluginDataSource DataSource => throw new NotSupportedException();
26-
public IPluginGraphAttributes GraphAttributes => throw new NotSupportedException();
27-
public INodeSessionCallback? SessionCallback => throw new NotSupportedException();
28-
}
29-
3022
private class PluginProvider(IReadOnlyCollection<IPlugin> plugins) : IPluginProvider {
3123
public IReadOnlyCollection<IPlugin> Plugins { get; } = plugins;
3224
public INodeSessionCallback? SessionCallback => null;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
// SPDX-License-Identifier: MIT
3+
using System;
4+
5+
using NUnit.Framework;
6+
7+
namespace Smdn.Net.MuninPlugin;
8+
9+
[TestFixture]
10+
public class MultigraphPluginTests {
11+
[TestCase(null, typeof(ArgumentNullException))]
12+
[TestCase("", typeof(ArgumentException))]
13+
[TestCase(" ", typeof(ArgumentException))]
14+
[TestCase("name", null)]
15+
public void Ctor_Name(string? name, Type? expectedArgumentExceptionType)
16+
=> Assert.That(
17+
() => new MultigraphPlugin(
18+
name: name!,
19+
plugins: []
20+
),
21+
expectedArgumentExceptionType is null
22+
? Throws.Nothing
23+
: Throws
24+
.TypeOf(expectedArgumentExceptionType)
25+
.With
26+
.Property(nameof(ArgumentException.ParamName))
27+
.EqualTo("name")
28+
);
29+
30+
[TestCase]
31+
public void Ctor_Plugins_ArgumentNull()
32+
=> Assert.That(
33+
() => new MultigraphPlugin(
34+
name: "multigraph",
35+
plugins: null!
36+
),
37+
Throws
38+
.ArgumentNullException
39+
.With
40+
.Property(nameof(ArgumentNullException.ParamName))
41+
.EqualTo("plugins")
42+
);
43+
}

0 commit comments

Comments
 (0)