Skip to content

Commit 79c95bc

Browse files
Added fixture based tests and re-enabled disabled tests (#310)
* Added fixture based tests and re-enabled disabled tests * Fixed settler tests and hardened settler a little bit more * lets keep this going * skip progress tests * equals was a mistake * progress tests * progress tests * progress tests * fixed bug in work done progress (not completeing correctly!) * Progress tests * some tests just aren't ready yet
1 parent 3161bfc commit 79c95bc

File tree

48 files changed

+1018
-518
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1018
-518
lines changed

src/Client/LanguageClientOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ ILanguageClientRegistry IJsonRpcHandlerRegistry<ILanguageClientRegistry>.AddHand
6161
ILanguageClientRegistry IJsonRpcHandlerRegistry<ILanguageClientRegistry>.AddHandler(string method, Type type, JsonRpcHandlerOptions options) =>
6262
AddHandler(method, type, options);
6363

64+
ILanguageClientRegistry IJsonRpcHandlerRegistry<ILanguageClientRegistry>.AddHandlerLink(string sourceMethod, string destinationMethod) =>
65+
AddHandlerLink(sourceMethod, destinationMethod);
66+
6467
ILanguageClientRegistry IJsonRpcHandlerRegistry<ILanguageClientRegistry>.OnJsonRequest(string method, Func<JToken, Task<JToken>> handler, JsonRpcHandlerOptions options) =>
6568
OnJsonRequest(method, handler, options);
6669

src/Dap.Client/DebugAdapterClientOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry<IDebugAdapterClientRegistry>
4949
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry<IDebugAdapterClientRegistry>.AddHandler(string method, Type type, JsonRpcHandlerOptions options) =>
5050
AddHandler(method, type, options);
5151

52+
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry<IDebugAdapterClientRegistry>.AddHandlerLink(string sourceMethod, string destinationMethod) =>
53+
AddHandlerLink(sourceMethod, destinationMethod);
54+
5255
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry<IDebugAdapterClientRegistry>.OnJsonRequest(
5356
string method, Func<JToken, Task<JToken>> handler, JsonRpcHandlerOptions options
5457
) => OnJsonRequest(method, handler, options);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
3+
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
34

45
namespace OmniSharp.Extensions.DebugAdapter.Protocol
56
{
67
public interface IProgressObservable : IObservable<ProgressEvent>
78
{
9+
ProgressToken ProgressToken { get; }
810
}
911
}

src/Dap.Protocol/Models/ProgressToken.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public bool Equals(ProgressToken other) =>
6969
String == other.String;
7070

7171
public bool Equals(long other) => IsLong && Long == other;
72-
7372
public bool Equals(string other) => IsString && String == other;
7473

7574
private string DebuggerDisplay => IsString ? String : IsLong ? Long.ToString() : "";

src/Dap.Server/DebugAdapterServerOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ IDebugAdapterServerRegistry IJsonRpcHandlerRegistry<IDebugAdapterServerRegistry>
3737
IDebugAdapterServerRegistry IJsonRpcHandlerRegistry<IDebugAdapterServerRegistry>.AddHandler(string method, Type type, JsonRpcHandlerOptions options) =>
3838
AddHandler(method, type, options);
3939

40+
IDebugAdapterServerRegistry IJsonRpcHandlerRegistry<IDebugAdapterServerRegistry>.AddHandlerLink(string sourceMethod, string destinationMethod) =>
41+
AddHandlerLink(sourceMethod, destinationMethod);
42+
4043
IDebugAdapterServerRegistry IJsonRpcHandlerRegistry<IDebugAdapterServerRegistry>.OnJsonRequest(
4144
string method, Func<JToken, Task<JToken>> handler, JsonRpcHandlerOptions options
4245
) => OnJsonRequest(method, handler, options);

src/JsonRpc.Testing/AggregateSettler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class AggregateSettler : ISettler
1313

1414
public AggregateSettler(params ISettler[] settlers) => _settlers = settlers;
1515

16-
public Task SettleNext() => Settle().Take(1).IgnoreElements().LastOrDefaultAsync().ToTask();
16+
public Task SettleNext() => Task.WhenAll(_settlers.Select(z => z.SettleNext()));
1717

1818
public IObservable<Unit> Settle() =>
1919
_settlers

src/JsonRpc.Testing/JsonRpcIntegrationServerTestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public JsonRpcIntegrationServerTestBase(JsonRpcTestOptions testOptions)
1919
_cancellationTokenSource = new CancellationTokenSource();
2020
if (!Debugger.IsAttached)
2121
{
22-
_cancellationTokenSource.CancelAfter(testOptions.TestTimeout);
22+
_cancellationTokenSource.CancelAfter(testOptions.CancellationTimeout);
2323
}
2424

25-
Events = ClientEvents = new Settler(TestOptions.SettleTimeSpan, TestOptions.SettleTimeout, CancellationToken);
25+
Events = ClientEvents = new Settler(TestOptions, CancellationToken);
2626
}
2727

2828
protected CompositeDisposable Disposable { get; }

src/JsonRpc.Testing/JsonRpcTestBase.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ public JsonRpcTestBase(JsonRpcTestOptions testOptions)
1919
_cancellationTokenSource = new CancellationTokenSource();
2020
if (!Debugger.IsAttached)
2121
{
22-
_cancellationTokenSource.CancelAfter(testOptions.TestTimeout);
22+
_cancellationTokenSource.CancelAfter(testOptions.CancellationTimeout);
2323
}
2424

25-
ClientEvents = new Settler(TestOptions.SettleTimeSpan, TestOptions.SettleTimeout, CancellationToken);
26-
ServerEvents = new Settler(TestOptions.SettleTimeSpan, TestOptions.SettleTimeout, CancellationToken);
25+
ClientEvents = new Settler(TestOptions, CancellationToken);
26+
ServerEvents = new Settler(TestOptions, CancellationToken);
2727
Events = new AggregateSettler(ClientEvents, ServerEvents);
2828
}
2929

3030
protected CompositeDisposable Disposable { get; }
31-
protected ISettler ClientEvents { get; }
32-
protected ISettler ServerEvents { get; }
33-
protected ISettler Events { get; }
34-
protected JsonRpcTestOptions TestOptions { get; }
35-
protected internal CancellationToken CancellationToken => _cancellationTokenSource.Token;
36-
protected Task SettleNext() => Events.SettleNext();
37-
protected IObservable<Unit> Settle() => Events.Settle();
31+
public ISettler ClientEvents { get; }
32+
public ISettler ServerEvents { get; }
33+
public ISettler Events { get; }
34+
public JsonRpcTestOptions TestOptions { get; }
35+
public CancellationToken CancellationToken => _cancellationTokenSource.Token;
36+
public Task SettleNext() => Events.SettleNext();
37+
public IObservable<Unit> Settle() => Events.Settle();
3838

3939
public void Dispose()
4040
{

src/JsonRpc.Testing/JsonRpcTestOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public JsonRpcTestOptions(ILoggerFactory clientLoggerFactory, ILoggerFactory ser
2121

2222
public ILoggerFactory ClientLoggerFactory { get; internal set; } = NullLoggerFactory.Instance;
2323
public ILoggerFactory ServerLoggerFactory { get; internal set; } = NullLoggerFactory.Instance;
24-
public TimeSpan SettleTimeSpan { get; internal set; } = TimeSpan.FromMilliseconds(100);
25-
public TimeSpan SettleTimeout { get; internal set; } = TimeSpan.FromMilliseconds(500);
26-
public TimeSpan TestTimeout { get; internal set; } = TimeSpan.FromMinutes(5);
24+
public TimeSpan WaitTime { get; internal set; } = TimeSpan.FromMilliseconds(50);
25+
public TimeSpan Timeout { get; internal set; } = TimeSpan.FromMilliseconds(500);
26+
public TimeSpan CancellationTimeout { get; internal set; } = TimeSpan.FromMinutes(5);
2727
public PipeOptions DefaultPipeOptions { get; internal set; } = new PipeOptions();
2828
}
2929
}

src/JsonRpc.Testing/JsonRpcTestOptionsExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ public static JsonRpcTestOptions WithClientLoggerFactory(this JsonRpcTestOptions
1818
return options;
1919
}
2020

21-
public static JsonRpcTestOptions WithSettleTimeSpan(this JsonRpcTestOptions options, TimeSpan settleTimeSpan)
21+
public static JsonRpcTestOptions WithWaitTime(this JsonRpcTestOptions options, TimeSpan waitTime)
2222
{
23-
options.SettleTimeSpan = settleTimeSpan;
23+
options.WaitTime = waitTime;
2424
return options;
2525
}
2626

27-
public static JsonRpcTestOptions WithSettleTimeout(this JsonRpcTestOptions options, TimeSpan timeout)
27+
public static JsonRpcTestOptions WithTimeout(this JsonRpcTestOptions options, TimeSpan timeout)
2828
{
29-
options.SettleTimeout = timeout;
29+
options.Timeout = timeout;
3030
return options;
3131
}
3232

33-
public static JsonRpcTestOptions WithTestTimeout(this JsonRpcTestOptions options, TimeSpan testTimeout)
33+
public static JsonRpcTestOptions WithCancellationTimeout(this JsonRpcTestOptions options, TimeSpan cancellationTimeout)
3434
{
35-
options.TestTimeout = testTimeout;
35+
options.CancellationTimeout = cancellationTimeout;
3636
return options;
3737
}
3838

0 commit comments

Comments
 (0)