Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marfusios committed Feb 15, 2024
1 parent 3249404 commit 35bc7ed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
2 changes: 2 additions & 0 deletions Binance.Client.Websocket.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B771F515-0677-409B-BEC1-B84BC88E7392}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
.github\workflows\dotnet-core-branches.yml = .github\workflows\dotnet-core-branches.yml
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net5;net6;net7;net8</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net6;net7;net8</TargetFrameworks>
<PackageId>Binance.Client.Websocket</PackageId>
<Authors>Mariusz Kotas</Authors>
<Description>Client for Binance websocket API</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,26 @@ public class BinanceWebsocketClientTests
public async Task Connect_ShouldWorkAndReceiveResponse()
{
var url = BinanceValues.ApiWebsocketUrl;
using (var communicator = new BinanceWebsocketCommunicator(url))
{
TradeResponse received = null;
var receivedEvent = new ManualResetEvent(false);

using (var client = new BinanceWebsocketClient(communicator))
{
using var communicator = new BinanceWebsocketCommunicator(url);
TradeResponse received = null;
var receivedEvent = new ManualResetEvent(false);

client.Streams.TradesStream.Subscribe(response =>
{
received = response;
receivedEvent.Set();
});
using var client = new BinanceWebsocketClient(communicator);
client.Streams.TradesStream.Subscribe(response =>
{
received = response;
receivedEvent.Set();
});

client.SetSubscriptions(
new TradeSubscription("btcusdt")
);
client.SetSubscriptions(
new TradeSubscription("btcusdt")
);

await communicator.Start();
await communicator.Start();

receivedEvent.WaitOne(TimeSpan.FromSeconds(30));
receivedEvent.WaitOne(TimeSpan.FromSeconds(30));

Assert.NotNull(received);
}
}
Assert.NotNull(received);

Check failure on line 37 in test_integration/Binance.Client.Websocket.Tests.Integration/BinanceWebsocketClientTests.cs

View workflow job for this annotation

GitHub Actions / tests

Binance.Client.Websocket.Tests.Integration.BinanceWebsocketClientTests ► Connect_ShouldWorkAndReceiveResponse

Failed test found in: test_integration/Binance.Client.Websocket.Tests.Integration/TestResults/tests.trx Error: Assert.NotNull() Failure: Value is null
Raw output
Assert.NotNull() Failure: Value is null
   at Binance.Client.Websocket.Tests.Integration.BinanceWebsocketClientTests.Connect_ShouldWorkAndReceiveResponse() in /home/runner/work/binance-client-websocket/binance-client-websocket/test_integration/Binance.Client.Websocket.Tests.Integration/BinanceWebsocketClientTests.cs:line 37
--- End of stack trace from previous location ---
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Binance.Client.Websocket.Subscriptions;
using Binance.Client.Websocket.Websockets;
using Xunit;

Expand All @@ -13,21 +12,19 @@ public class BinanceWebsocketCommunicatorTests
public async Task OnStarting_ShouldGetInfoResponse()
{
var url = BinanceValues.ApiWebsocketUrl;
using (var communicator = new BinanceWebsocketCommunicator(url))
{
var receivedEvent = new ManualResetEvent(false);
using var communicator = new BinanceWebsocketCommunicator(url);
var receivedEvent = new ManualResetEvent(false);

communicator.MessageReceived.Subscribe(msg =>
{
receivedEvent.Set();
});
communicator.MessageReceived.Subscribe(msg =>
{
receivedEvent.Set();
});

communicator.Url = new Uri(url + "stream?streams=btcusdt@trade");
communicator.Url = new Uri(url + "stream?streams=btcusdt@trade");

await communicator.Start();
await communicator.Start();

receivedEvent.WaitOne(TimeSpan.FromSeconds(30));
}
receivedEvent.WaitOne(TimeSpan.FromSeconds(30));
}
}
}

0 comments on commit 35bc7ed

Please sign in to comment.