Skip to content

Commit 63d9b7c

Browse files
Fix failing test (#6)
* Updated timeout for test to run on appveyor * More trying to fix testing * reset changes to output handler * use all threads for the build
1 parent c171e34 commit 63d9b7c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Task("Coverage")
7878
.Append("xunit")
7979
.Append("-noshadow")
8080
.Append("-noautoreporters")
81-
.AppendSwitch("-maxthreads", "1")
81+
// .AppendSwitch("-maxthreads", "1")
8282
.AppendSwitch("-configuration", configuration)
8383
.AppendSwitch("-framework", "net46")
8484
.AppendSwitchQuotedSecret("-xml", string.Format("{0}/tests/{1}.xml", artifacts, testProject.GetFilenameWithoutExtension()))

test/JsonRpc.Tests/OutputHandlerTests.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
using System;
22
using System.IO;
33
using System.Threading;
4+
using System.Threading.Tasks;
45
using NSubstitute;
56
using Xunit;
67

78
namespace JsonRpc.Tests
89
{
910
public class OutputHandlerTests
1011
{
11-
private static (OutputHandler handler, Action wait) NewHandler(TextWriter textWriter,Action<CancellationTokenSource> action)
12+
private static (OutputHandler handler, Func<Task> wait) NewHandler(TextWriter textWriter,Action<CancellationTokenSource> action)
1213
{
1314
var cts = new CancellationTokenSource();
1415
if (!System.Diagnostics.Debugger.IsAttached)
15-
cts.CancelAfter(TimeSpan.FromSeconds(5));
16+
cts.CancelAfter(TimeSpan.FromSeconds(120));
1617
action(cts);
1718

1819
var handler = new OutputHandler(textWriter);
1920
handler.Start();
20-
return (handler, () => cts.Wait());
21+
return (handler, () => {
22+
cts.Wait();
23+
return Task.Delay(50);
24+
});
2125
}
2226

2327
[Fact]
24-
public void ShouldSerializeValues()
28+
public async Task ShouldSerializeValues()
2529
{
2630
var tw = Substitute.For<TextWriter>();
2731

@@ -35,7 +39,7 @@ public void ShouldSerializeValues()
3539
{
3640

3741
handler.Send(value);
38-
wait();
42+
await wait();
3943

4044
tw.Received().Write("Content-Length: 46\r\n\r\n{\"protocolVersion\":\"2.0\",\"id\":1,\"result\":null}");
4145
}

0 commit comments

Comments
 (0)