Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
cd21e82
- fixing namespace issue
ppanchen Sep 29, 2025
83122dd
- comment added
ppanchen Sep 29, 2025
a2acbea
Merge pull request #15 from ppanchen/lab2
ppanchen Sep 29, 2025
5bfdf16
- added test coverage
ppanchen Oct 6, 2025
ba1f4b0
Merge pull request #36 from ppanchen/lab3
ppanchen Oct 6, 2025
b2d1b44
- fixed typo
ppanchen Oct 17, 2025
bb1f6df
- added architecture tests
ppanchen Oct 17, 2025
85a0778
Merge pull request #45 from ppanchen/lab5
ppanchen Oct 17, 2025
02bc9b1
Update sonarcloud.yml
euviola Oct 18, 2025
8e78f0d
Create sonar-project.properties
euviola Oct 18, 2025
5044792
Create sonar-project.properties
euviola Oct 18, 2025
ebea543
Delete .github/sonar-project.properties
euviola Oct 18, 2025
8dba492
Delete .github/workflows/sonar-project.properties
euviola Oct 18, 2025
c20187b
Create sonar-project.properties
euviola Oct 18, 2025
568d7ef
Update README.md
euviola Oct 18, 2025
223e1e9
Made CancellationTokenSource readonly
euviola Nov 4, 2025
c81474b
Made HandleClientAsync static
euviola Nov 4, 2025
3eb056c
made _tcpClient readonly
euviola Nov 4, 2025
14bafb9
Removed Empty Statement
euviola Nov 4, 2025
125c2c6
Removed the unused variable "type"
euviola Nov 4, 2025
012d402
Made _udpClient_MessageReceived static
euviola Nov 4, 2025
1de6f78
Small fixes
euviola Nov 4, 2025
8d071b1
Lab3 commits (UnitTests)
euviola Nov 5, 2025
93564b7
Fixes
euviola Nov 5, 2025
4d912dc
Added Coverage
euviola Nov 5, 2025
cebbc37
Coverage fix
euviola Nov 5, 2025
67b2148
fixes
euviola Nov 5, 2025
aac9481
Mockups changed, fixed build issues
euviola Nov 5, 2025
5c84ec7
Update sonarcloud.yml
euviola Nov 5, 2025
a69b477
Coverage fix
euviola Nov 5, 2025
0e7709f
Still trying to fix the coverage
euviola Nov 5, 2025
8cc9c38
Lord, have mercy.
euviola Nov 5, 2025
5cff763
bullshit
euviola Nov 5, 2025
b6ee4ad
omg
euviola Nov 5, 2025
349ffe4
pls work
euviola Nov 5, 2025
ad4175e
2142124
euviola Nov 5, 2025
b2ceb5c
jusst work pls
euviola Nov 5, 2025
8d5af71
once again
euviola Nov 5, 2025
f8c1c50
22
euviola Nov 5, 2025
73412c8
Update sonarcloud.yml
euviola Nov 5, 2025
865b034
Update sonarcloud.yml
euviola Nov 6, 2025
89d974a
Update sonarcloud.yml
euviola Nov 6, 2025
7502963
Update sonarcloud.yml
euviola Nov 7, 2025
e050346
Update sonarcloud.yml
euviola Nov 7, 2025
e3b9eff
Update sonarcloud.yml
euviola Nov 7, 2025
12851bb
delete --no-build
euviola Nov 7, 2025
7ca8ae9
Update sonarcloud.yml
euviola Nov 7, 2025
4550e16
Coverage fixing
euviola Nov 7, 2025
44c2bfd
yet another fix
euviola Nov 7, 2025
ea04df6
another fix
euviola Nov 7, 2025
8951a49
Update sonarcloud.yml
euviola Nov 7, 2025
3e3659e
exclusions
euviola Nov 7, 2025
7b426b6
back in black
euviola Nov 7, 2025
953b38c
Updated tests
euviola Nov 7, 2025
178ad56
Update NetSdrClient.cs
euviola Nov 7, 2025
e266afe
Update NetSdrClientTests.cs
euviola Nov 7, 2025
4ba8871
Update NetSdrClientTests.cs
euviola Nov 7, 2025
4b23ce6
UdpClientWrapper: duplication fixes
euviola Nov 7, 2025
812403d
DuplicationFixes
euviola Nov 7, 2025
a367473
Still fixing
euviola Nov 7, 2025
f2eafa2
Lab4: Coverage fix
euviola Nov 7, 2025
94ddfe2
Architecture tests + BadReference
euviola Nov 17, 2025
3caff69
Delete BadRefrence to Fix ArchitectureTests + TestsFixes
euviola Nov 17, 2025
da4dbd3
Lab6 omg
euviola Nov 17, 2025
d3d8f7e
Remade tests
euviola Nov 17, 2025
2eb646a
Update sonarcloud.yml
euviola Nov 17, 2025
bd3cca7
Update sonarcloud.yml
euviola Nov 17, 2025
497ec22
Update sonarcloud.yml
euviola Nov 18, 2025
5c227cc
lab7
euviola Nov 18, 2025
dfe71b7
add dependabot
euviola Nov 18, 2025
8cdcd9f
Bump NUnit from 3.14.0 to 4.4.0
dependabot[bot] Nov 18, 2025
821e35e
Merge pull request #4 from euviola/dependabot/nuget/EchoTcpServer/mul…
euviola Nov 18, 2025
383fc1c
Updating
euviola Nov 18, 2025
10b126c
Merge branch 'master' of https://github.com/euviola/NetSdrClient
euviola Nov 19, 2025
711afc5
Bring back coverage
euviola Nov 19, 2025
5f746e3
Update sonarcloud.yml
euviola Nov 19, 2025
a53471c
Update sonarcloud.yml
euviola Nov 19, 2025
f02e558
Update sonarcloud.yml
euviola Nov 19, 2025
82cd18f
Trying to bring back coverage once again omg
euviola Nov 19, 2025
657db2e
same shit
euviola Nov 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"
20 changes: 10 additions & 10 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ jobs:
dotnet tool install --global dotnet-sonarscanner
echo "$env:USERPROFILE\.dotnet\tools" >> $env:GITHUB_PATH
dotnet sonarscanner begin `
/k:"ppanchen_NetSdrClient" `
/o:"ppanchen" `
/k:"euviola_NetSdrClient" `
/o:"euviola" `
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" `
/d:sonar.cs.opencover.reportsPaths="**/coverage.xml" `
/d:sonar.cpd.cs.minimumTokens=40 `
Expand All @@ -70,14 +70,14 @@ jobs:
run: dotnet restore NetSdrClient.sln
- name: Build
run: dotnet build NetSdrClient.sln -c Release --no-restore
#- name: Tests with coverage (OpenCover)
# run: |
# dotnet test NetSdrClientAppTests/NetSdrClientAppTests.csproj -c Release --no-build `
# /p:CollectCoverage=true `
# /p:CoverletOutput=TestResults/coverage.xml `
# /p:CoverletOutputFormat=opencover
# shell: pwsh
- name: Tests with coverage (OpenCover)
run: |
dotnet test NetSdrClientAppTests/NetSdrClientAppTests.csproj -c Release --no-build `
/p:CollectCoverage=true `
/p:CoverletOutput=TestResults/coverage.xml `
/p:CoverletOutputFormat=opencover
shell: pwsh
# 3) END: SonarScanner
- name: SonarScanner End
run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
shell: pwsh
shell: pwsh
17 changes: 17 additions & 0 deletions EchoTcpServer/EchoClientHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Net.Sockets;

public class EchoClientHandler : IClientHandler
{
public async Task HandleAsync(TcpClient client, CancellationToken token)
{
using var stream = client.GetStream();
byte[] buffer = new byte[8192];

int bytesRead;
while (!token.IsCancellationRequested &&
(bytesRead = await stream.ReadAsync(buffer, token)) > 0)
{
await stream.WriteAsync(buffer.AsMemory(0, bytesRead), token);
}
}
}
49 changes: 49 additions & 0 deletions EchoTcpServer/EchoServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace EchoServer
{
public class EchoServer
{
private readonly ITcpListener _listener;
private readonly IClientHandler _handler;
private readonly CancellationTokenSource _cancellationTokenSource;

public EchoServer(ITcpListener listener, IClientHandler handler)
{
_listener = listener;
_handler = handler;
_cancellationTokenSource = new CancellationTokenSource();
}

public async Task StartAsync()
{
_listener.Start();

while (!_cancellationTokenSource.Token.IsCancellationRequested)
{
TcpClient client;
try
{
client = await _listener.AcceptTcpClientAsync();
}
catch (ObjectDisposedException)
{
break;
}

_ = Task.Run(() => _handler.HandleAsync(client, _cancellationTokenSource.Token));
}
}

public void Stop()
{
_cancellationTokenSource.Cancel();
_listener.Stop();
}
}
}
19 changes: 19 additions & 0 deletions EchoTcpServer/EchoServer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
<PackageReference Include="SharpZipLib" Version="1.3.3" />
</ItemGroup>

</Project>
52 changes: 52 additions & 0 deletions EchoTcpServer/EchoServerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using NSubstitute;
using NUnit.Framework;

namespace EchoServerTests
{
public class EchoServerTests
{
[Test]
public async Task StartAsync_StartsListener_AndStopsAfterCancel()
{
var listener = Substitute.For<ITcpListener>();

listener.AcceptTcpClientAsync().Returns(async _ =>
{
await Task.Delay(Timeout.Infinite);
return new TcpClient();
});

var handler = Substitute.For<IClientHandler>();

var server = new EchoServer.EchoServer(listener, handler);

var runTask = server.StartAsync();

await Task.Delay(50);

listener.Received(1).Start();

server.Stop();

await Task.Delay(50);

listener.Received(1).Stop();
}

[Test]
public void Stop_Should_Stop_Listener_Immediately()
{
var listener = Substitute.For<ITcpListener>();
var handler = Substitute.For<IClientHandler>();

var server = new EchoServer.EchoServer(listener, handler);

server.Stop();

listener.Received(1).Stop();
}
}
}
6 changes: 6 additions & 0 deletions EchoTcpServer/IClientHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System.Net.Sockets;

public interface IClientHandler
{
Task HandleAsync(TcpClient client, CancellationToken token);
}
9 changes: 9 additions & 0 deletions EchoTcpServer/ITcpListener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Net.Sockets;
using System.Net;

public interface ITcpListener
{
void Start();
void Stop();
Task<TcpClient> AcceptTcpClientAsync();
}
20 changes: 20 additions & 0 deletions EchoTcpServer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EchoServer;

public static class Program
{
public static async Task Main(string[] args)
{
var listener = new TcpListenerWrapper(IPAddress.Any, 5000);
var handler = new EchoClientHandler();

var server = new EchoServer.EchoServer(listener, handler);

await server.StartAsync();
}
}
17 changes: 17 additions & 0 deletions EchoTcpServer/TcpListenerWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Net;
using System.Net.Sockets;

public class TcpListenerWrapper : ITcpListener
{
private readonly TcpListener _listener;

public TcpListenerWrapper(IPAddress address, int port)
{
_listener = new TcpListener(address, port);
}

public void Start() => _listener.Start();
public void Stop() => _listener.Stop();
public Task<TcpClient> AcceptTcpClientAsync() => _listener.AcceptTcpClientAsync();
}
10 changes: 0 additions & 10 deletions EchoTspServer/EchoServer.csproj

This file was deleted.

Loading