Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marfusios committed Sep 6, 2023
1 parent 1206ac2 commit 233e1bd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Websocket.Client/Threading/WebsocketAsyncLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Task<IDisposable> LockAsync()
return waitTask.IsCompleted
? _releaserTask
: waitTask.ContinueWith(
(_, releaser) => (IDisposable)releaser,
(_, releaser) => (IDisposable)releaser!,
_releaser,
CancellationToken.None,
TaskContinuationOptions.ExecuteSynchronously,
Expand Down
1 change: 1 addition & 0 deletions src/Websocket.Client/Websocket.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="" />
<None Include="icon-modern.png" Pack="true" PackagePath="" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

Expand Down
Binary file removed src/Websocket.Client/icon-modern.jpg
Binary file not shown.
Binary file added src/Websocket.Client/icon-modern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 13 additions & 6 deletions test/Websocket.Client.Tests/Testserver/TestContext.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
using System;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Events;
using Serilog.Extensions.Logging;
using Xunit.Abstractions;

namespace Websocket.Client.Tests.TestServer
{
public class TestContext<TStartup> where TStartup : class
{
private readonly TestServerApplicationFactory<TStartup> _factory;
private readonly ILogger<WebsocketClient> _logger;

public TestContext(ITestOutputHelper output)
{
_factory = new TestServerApplicationFactory<TStartup>();
InitLogging(output);
var factory = InitLogging(output);
if (factory != null)
_logger = factory.CreateLogger<WebsocketClient>();
}

public WebSocketClient NativeTestClient { get; set; }
Expand All @@ -33,7 +38,7 @@ public IWebsocketClient CreateClient(Uri serverUrl)
Scheme = "ws",
Path = "ws"
}.Uri;
return new WebsocketClient(wsUri,
return new WebsocketClient(wsUri, _logger,
async (uri, token) =>
{
if (_factory.Server == null)
Expand All @@ -60,19 +65,21 @@ public IWebsocketClient CreateInvalidClient(Uri serverUrl)
Scheme = "ws",
Path = "ws"
}.Uri;
return new WebsocketClient(wsUri,
return new WebsocketClient(wsUri, _logger,
(uri, token) => throw new InvalidOperationException("Connection to websocket server failed, check url"));
}

private void InitLogging(ITestOutputHelper output)
private SerilogLoggerFactory InitLogging(ITestOutputHelper output)
{
if (output == null)
return;
return null;

Log.Logger = new LoggerConfiguration()
var logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.TestOutput(output, LogEventLevel.Verbose)
.CreateLogger();
Log.Logger = logger;
return new SerilogLoggerFactory(logger);
}
}
}
1 change: 1 addition & 0 deletions test/Websocket.Client.Tests/Websocket.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.5" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 233e1bd

Please sign in to comment.