Skip to content

Commit 5c3c5da

Browse files
Martin LercherMartin Lercher
authored andcommitted
Test for permanent thread name
1 parent 33f6427 commit 5c3c5da

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/JsonRpc.Tests/InputHandlerTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,34 @@ public void ShouldPassInRequests()
7070
}
7171
}
7272

73+
[Fact]
74+
public void ShouldHaveAThreadName()
75+
{
76+
var threadName = "(untouched)";
77+
var inputStream = new MemoryStream(Encoding.ASCII.GetBytes("Content-Length: 2\r\n\r\n{}"));
78+
var reciever = Substitute.For<IReciever>();
79+
80+
using (NewHandler(
81+
inputStream,
82+
Substitute.For<IOutputHandler>(),
83+
reciever,
84+
Substitute.For<IRequestProcessIdentifier>(),
85+
Substitute.For<IRequestRouter>(),
86+
Substitute.For<IResponseRouter>(),
87+
cts => {
88+
reciever.When(x => x.IsValid(Arg.Any<JToken>()))
89+
.Do(x => {
90+
threadName = System.Threading.Thread.CurrentThread.Name;
91+
cts.Cancel();
92+
});
93+
}))
94+
{
95+
reciever.Received();
96+
threadName.Should().Be("ProcessInputStream", because: "it is easier to find it in the Threads pane by it's name");
97+
}
98+
99+
}
100+
73101
[Fact]
74102
public void ShouldPassInUtf8EncodedRequests()
75103
{

0 commit comments

Comments
 (0)