Skip to content

Commit 37a88cd

Browse files
committed
clean up
1 parent ae1b796 commit 37a88cd

File tree

10 files changed

+14
-48
lines changed

10 files changed

+14
-48
lines changed

tests/Smdn.Net.MuninNode.Hosting/Smdn.Net.MuninNode.Hosting/MuninNodeBackgroundService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private class NullMuninNode : IMuninNode {
230230
public EndPoint EndPoint { get; } = new IPEndPoint(IPAddress.Any, 0);
231231

232232
public Task RunAsync(CancellationToken cancellationToken)
233-
=> Task.Run(() => cancellationToken.WaitHandle.WaitOne());
233+
=> Task.Run(cancellationToken.WaitHandle.WaitOne);
234234
}
235235

236236
[Test]

tests/Smdn.Net.MuninNode/Smdn.Net.MuninNode.AccessRules/AddressListAccessRule.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3-
using System;
43
using System.Net;
54

65
using NUnit.Framework;

tests/Smdn.Net.MuninNode/Smdn.Net.MuninNode.AccessRules/LoopbackOnlyAccessRule.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3-
using System;
4-
using System.Net;
5-
63
using NUnit.Framework;
74

85
namespace Smdn.Net.MuninNode.AccessRules;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ public void AddNode_Multiple_GetKeyedService(string hostName)
167167
}
168168

169169
private class CustomMuninNodeBuilder<TMuninNodeOptions> : MuninNodeBuilder
170-
where TMuninNodeOptions : MuninNodeOptions
171-
{
170+
where TMuninNodeOptions : MuninNodeOptions {
172171
private readonly Func<TMuninNodeOptions, IPluginProvider, IMuninNodeListenerFactory?, IServiceProvider, IMuninNode> nodeFactory;
173172

174173
public CustomMuninNodeBuilder(

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3-
using System;
4-
53
using NUnit.Framework;
64

75
namespace Smdn.Net.MuninNode.Protocol;

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,15 @@ public void HandleTransactionStartAsync_CancellationRequested()
125125
profile: new MuninNodeProfile()
126126
);
127127
var client = new PseudoMuninNodeClient();
128-
using var cts = new CancellationTokenSource();
129-
130-
cts.Cancel();
128+
var cancellationToken = new CancellationToken(canceled: true);
131129

132130
Assert.That(
133-
async () => await handler.HandleTransactionStartAsync(client, cts.Token),
131+
async () => await handler.HandleTransactionStartAsync(client, cancellationToken),
134132
Throws
135133
.InstanceOf<OperationCanceledException>()
136134
.With
137135
.Property(nameof(OperationCanceledException.CancellationToken))
138-
.EqualTo(cts.Token)
136+
.EqualTo(cancellationToken)
139137
);
140138

141139
Assert.That(client.Responses.Count, Is.Zero);
@@ -184,17 +182,15 @@ public void HandleTransactionEndAsync_CancellationRequested()
184182
profile: new MuninNodeProfile()
185183
);
186184
var client = new PseudoMuninNodeClient();
187-
using var cts = new CancellationTokenSource();
188-
189-
cts.Cancel();
185+
var cancellationToken = new CancellationToken(canceled: true);
190186

191187
Assert.That(
192-
async () => await handler.HandleTransactionEndAsync(client, cts.Token),
188+
async () => await handler.HandleTransactionEndAsync(client, cancellationToken),
193189
Throws
194190
.InstanceOf<OperationCanceledException>()
195191
.With
196192
.Property(nameof(OperationCanceledException.CancellationToken))
197-
.EqualTo(cts.Token)
193+
.EqualTo(cancellationToken)
198194
);
199195

200196
Assert.That(client.Responses.Count, Is.Zero);
@@ -227,17 +223,15 @@ public void HandleCommandAsync_CancellationRequested()
227223
profile: new MuninNodeProfile()
228224
);
229225
var client = new PseudoMuninNodeClient();
230-
using var cts = new CancellationTokenSource();
231-
232-
cts.Cancel();
226+
var cancellationToken = new CancellationToken(canceled: true);
233227

234228
Assert.That(
235-
async () => await handler.HandleCommandAsync(client, CreateCommandLineSequence("."), cts.Token),
229+
async () => await handler.HandleCommandAsync(client, CreateCommandLineSequence("."), cancellationToken),
236230
Throws
237231
.InstanceOf<OperationCanceledException>()
238232
.With
239233
.Property(nameof(OperationCanceledException.CancellationToken))
240-
.EqualTo(cts.Token)
234+
.EqualTo(cancellationToken)
241235
);
242236

243237
Assert.That(client.Responses.Count, Is.Zero);

tests/Smdn.Net.MuninNode/Smdn.Net.MuninNode/NodeBase.Commands.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7-
using System.Linq;
87
using System.Threading;
98
using System.Threading.Tasks;
109

@@ -81,18 +80,6 @@ private static Task RunSessionAsync(
8180
cancellationToken: cancellationToken
8281
);
8382

84-
private static Task RunSessionAsync(
85-
IReadOnlyList<IPlugin>? plugins,
86-
Func<PseudoMuninNode, PseudoMuninNodeClient, TextWriter, TextReader, CancellationToken, Task> action,
87-
CancellationToken cancellationToken = default
88-
)
89-
=> RunSessionAsync(
90-
accessRule: null,
91-
plugins: plugins,
92-
action: action,
93-
cancellationToken: cancellationToken
94-
);
95-
9683
private static async Task RunSessionAsync(
9784
IAccessRule? accessRule,
9885
IReadOnlyList<IPlugin>? plugins,

tests/Smdn.Net.MuninNode/Smdn.Net.MuninNode/NodeBase.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ protected override ValueTask StoppedAsync(CancellationToken cancellationToken)
130130
private static NodeBase CreateNode()
131131
=> CreateNode(accessRule: null, plugins: Array.Empty<IPlugin>());
132132

133-
private static NodeBase CreateNode(IReadOnlyList<IPlugin> plugins)
134-
=> CreateNode(accessRule: null, plugins: plugins);
135-
136133
private static NodeBase CreateNode(IAccessRule? accessRule, IReadOnlyList<IPlugin> plugins)
137134
=> new TestLocalNode(accessRule, plugins);
138135

@@ -358,7 +355,7 @@ public async Task StopAsync_StartedByStart()
358355
await using var node = CreateNode();
359356

360357
#pragma warning disable CS0618
361-
Assert.That(() => node.Start(), Throws.Nothing);
358+
Assert.That(node.Start, Throws.Nothing);
362359
#pragma warning restore CS0618
363360

364361
Assert.That(async () => await node.StopAsync(default), Throws.Nothing);

tests/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/AggregatePluginProvider.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,8 @@ public void INodeSessionCallback_ReportSessionStartedAsync_CancellationRequested
195195

196196
INodeSessionCallback sessionCallback = pluginProviderCollections;
197197

198-
using var cts = new CancellationTokenSource(0);
199-
200198
Assert.That(
201-
async () => await sessionCallback.ReportSessionStartedAsync(string.Empty, cts.Token),
199+
async () => await sessionCallback.ReportSessionStartedAsync(string.Empty, cancellationToken: new(canceled: true)),
202200
Throws.InstanceOf<OperationCanceledException>()
203201
);
204202

@@ -221,10 +219,8 @@ public void INodeSessionCallback_ReportSessionClosedAsync_CancellationRequested(
221219

222220
INodeSessionCallback sessionCallback = pluginProviderCollections;
223221

224-
using var cts = new CancellationTokenSource(0);
225-
226222
Assert.That(
227-
async () => await sessionCallback.ReportSessionClosedAsync(string.Empty, cts.Token),
223+
async () => await sessionCallback.ReportSessionClosedAsync(string.Empty, cancellationToken: new(canceled: true)),
228224
Throws.InstanceOf<OperationCanceledException>()
229225
);
230226

tests/Smdn.Net.MuninNode/Smdn.Net.MuninPlugin/PluginGraphAttributesBuilder.GraphArgs.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
33
using System;
4-
using System.Collections.Generic;
54

65
using NUnit.Framework;
76

0 commit comments

Comments
 (0)