Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
560f936
update langversion to the latest version
thigiang16 Nov 23, 2025
0f97a93
implement RunTaskAsync and test
thigiang16 Nov 23, 2025
f123055
implement RunAsync and tests
thigiang16 Nov 23, 2025
0976d41
removed /* */ to restore code
thigiang16 Nov 24, 2025
03c675a
Bullet Points 4 and 5
ulises-aguilar Nov 25, 2025
1bf1d90
Tests for PingProcess
ulises-aguilar Nov 26, 2025
b74fba4
modify #1
thigiang16 Nov 27, 2025
07e1c71
update methods and tests
thigiang16 Nov 27, 2025
d1e453b
fix
thigiang16 Nov 27, 2025
1148af7
Tests
ulises-aguilar Nov 29, 2025
3161991
Test fixes
ulises-aguilar Nov 29, 2025
fee60a2
extra credit attempt
thigiang16 Nov 30, 2025
669811e
Fixing test
ulises-aguilar Nov 30, 2025
0de6beb
removed some comments
thigiang16 Dec 2, 2025
b80f351
Use ThrowIfNull instead of manual null checks
thigiang16 Dec 2, 2025
07889e6
fix namespace
thigiang16 Dec 2, 2025
691e996
fix bug
thigiang16 Dec 2, 2025
6957474
fix CA2263 warning
thigiang16 Dec 2, 2025
ca3ee88
WildCardPattern File corrections.
ulises-aguilar Dec 3, 2025
c724436
limits pings on linux
thigiang16 Dec 3, 2025
ee40261
limits ping
thigiang16 Dec 3, 2025
ba4ebab
limits ping again
thigiang16 Dec 3, 2025
94f89e1
fix again
thigiang16 Dec 3, 2025
c040a68
added mockpingprocess
thigiang16 Dec 3, 2025
b6a576c
Fixing Error.
ulises-aguilar Dec 3, 2025
a132066
CA1847 fix
ulises-aguilar Dec 3, 2025
be44668
Fixing MockPingProcess file.
ulises-aguilar Dec 3, 2025
012c120
Fixing error.
ulises-aguilar Dec 3, 2025
0bef52f
fixing error.
ulises-aguilar Dec 3, 2025
bcfaecc
removed extra credit's test
thigiang16 Dec 3, 2025
ee6179d
update #1,#2,#3,#4
thigiang16 Dec 5, 2025
a88f368
update 5 and extra credit
thigiang16 Dec 5, 2025
01172cc
added assert.fail message
thigiang16 Dec 5, 2025
f1574fb
Fix StringBuilder parallel test: works locally but fails on CI
thigiang16 Dec 5, 2025
70c76c0
added more tests
thigiang16 Dec 5, 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
18 changes: 13 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

# Created by https://www.gitignore.io/api/csharp
# Edit at https://www.gitignore.io/?templates=csharp

### Csharp ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand Down Expand Up @@ -29,7 +34,6 @@ bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down Expand Up @@ -127,6 +131,9 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

Expand Down Expand Up @@ -346,8 +353,9 @@ healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# End of https://www.gitignore.io/api/csharp

# Mac specific files
.DS_Store

# Live unit testing files.
*.lutconfig
*.sqlite
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<ProjectReference Include="..\Assignment\Assignment.csproj" />
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<ProjectReference Include="..\Assignment\Assignment.csproj" />
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
65 changes: 65 additions & 0 deletions Assignment.Tests/MockPingProcess.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using Assignment;
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;

namespace Assignment.Tests;

internal sealed class MockPingProcess : PingProcess
{
private readonly string _pingTemplate = @"
Pinging * with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

Ping statistics for ::1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms".Trim();

protected override int RunProcessInternal(
ProcessStartInfo startInfo,
Action<string?>? stdoutCallback,
Action<string?>? stderrCallback,
CancellationToken cancellationToken)
{
// simulate network delay
Task.Delay(400, cancellationToken).Wait(cancellationToken);

string host = startInfo.Arguments?.Split(' ')[0] ?? "localhost";

// simulate a host not found
if (host.Equals("badaddress", StringComparison.OrdinalIgnoreCase))
{
string message = $"Ping request could not find host {host}. Please check the name and try again.";
stdoutCallback?.Invoke(message);
stdoutCallback?.Invoke(null);
stderrCallback?.Invoke(null);
return 1;
}

// output fake ping results
foreach (var line in GenerateLines(host))
{
stdoutCallback?.Invoke(line);
}

stdoutCallback?.Invoke(null);
stderrCallback?.Invoke(null);

return 0;
}

private string[] GenerateLines(string host)
{
string[] lines = _pingTemplate.Split(Environment.NewLine, StringSplitOptions.None);
if (lines.Length > 0 && lines[0].Contains('*'))
{
lines[0] = lines[0].Replace("*", host);
}
return lines;
}
}
Loading