Skip to content

Conversation

@Hellothereyoko
Copy link

Just me again, did my best to follow along

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

Summary

Summary
Generated on: 12/04/2025 - 08:05:35
Coverage date: 12/04/2025 - 08:05:32
Parser: MultiReport (2x Cobertura)
Assemblies: 1
Classes: 2
Files: 1
Line coverage: 86.6% (143 of 165)
Covered lines: 143
Uncovered lines: 22
Coverable lines: 165
Total lines: 326
Branch coverage: 75% (36 of 48)
Covered branches: 36
Total branches: 48
Method coverage: Feature is only available for sponsors
Tag: 572_19921901429

Coverage

Assignment - 86.6%
Name Line Branch
Assignment 86.6% 75%
Assignment.PingProcess 86.5% 75%
Assignment.PingResult 100%

Copy link

@RyanHirte RyanHirte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement PingProcess' public Task RunTaskAsync(string hostNameOrAddress) ✔
First implement public void RunTaskAsync_Success() test method to test PingProcess.RunTaskAsync() using "localhost". ✔
Do NOT use async/await in this implementation. ✔
Implement PingProcess' async public Task RunAsync(string hostNameOrAddress) ✔
First implement the public void RunAsync_UsingTaskReturn_Success() test method to test PingProcess.RunAsync() using "localhost" without using async/await. ✔
Also implement the async public Task RunAsync_UsingTpl_Success() test method to test PingProcess.RunAsync() using "localhost" but this time DO using async/await. ✔
Add support for an optional cancellation token to the PingProcess.RunAsync() signature. ✔ Inside the PingProcess.RunAsync() invoke the token's ThrowIfCancellationRequested() method so an exception is thrown. ✔ Test that, when cancelled from the test method, the exception thrown is an AggregateException ✔ with a TaskCanceledException inner exception ✔ using the test methods RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrapping ✔and RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrappingTaskCanceledException ✔ respectively.
Complete/fix AND test async public Task RunAsync(IEnumerable hostNameOrAddresses, CancellationToken cancellationToken = default) which executes ping for an array of hostNameOrAddresses (which can all be "localhost") in parallel, adding synchronization if needed. ✔ NOTE:
The order of the items in the stdOutput is irrelevant and expected to be intermingled.
StdOutput must have all the ping output returned (no lines can be missing) even though intermingled. ✔
Implement AND test public Task RunLongRunningAsync(ProcessStartInfo startInfo, Action<string?>? progressOutput, Action<string?>? progressError, CancellationToken token) using Task.Factory.StartNew() and invoking RunProcessInternal with a TaskCreation value of TaskCreationOptions.LongRunning and a TaskScheduler value of TaskScheduler.Current. Returning a Task is also okay. NOTE: This method does NOT use Task.Run.✔

Extra credit not implemented

Place all shared project properties into a Directory.Build.Props file.
Place all shared project items into a Directory.Build.targets file.
Ensure nullable reference types is enabled ✔
Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ✔
and enabled .NET analyzers for both projects ✔
For this assignment, consider using Assert.AreEqual() (the generic version) ❌
All of the above should be unit tested ✔
Choose simplicity over complexity ✔

Overall good job just some nitpicks, also I think you are missing your gitignore, I can't find it in the base directory of your branch, and having it gone may be why your pr has 435 file changes.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick but don't need this here since it's in your build.props

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in your build.props so don't need it here.

[Timeout(10000)] // 10 second timeout
public void RunTaskAsync_Success()
{
const string host = "localhost";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of tests have this same line, could put it at the top of the test class next to _pingProcess that way all tests have access to it and you don't need to declare it every single test.

task.Wait();
PingResult result = task.Result;

Assert.AreEqual(0, result.ExitCode);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the generic version of areEqual()

@ColtonKnopik
Copy link

You should look at your implementation and find ways to optimize your file structure

@kellanburns
Copy link

Instructions

  1. Implement PingProcess' public Task<PingResult> RunTaskAsync(string hostNameOrAddress)
    • First implement public void RunTaskAsync_Success() test method to test PingProcess.RunTaskAsync() using "localhost". ✔
    • Do NOT use async/await in this implementation. ✔
  2. Implement PingProcess' async public Task<PingResult> RunAsync(string hostNameOrAddress)
    • First implement the public void RunAsync_UsingTaskReturn_Success() test method to test PingProcess.RunAsync() using "localhost" without using async/await. ✔
    • Also implement the async public Task RunAsync_UsingTpl_Success() test method to test PingProcess.RunAsync() using "localhost" but this time DO using async/await. ✔
  3. Add support for an optional cancellation token to the PingProcess.RunAsync() signature. ✔
    Inside the PingProcess.RunAsync() invoke the token's ThrowIfCancellationRequested() method so an exception is thrown. ✔
    Test that, when cancelled from the test method, the exception thrown is an AggregateException ✔ with a TaskCanceledException inner exception using the test methods ❌ Wrong exception type, 'OperationCanceledException'
    RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrapping ✔and RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrappingTaskCanceledException ✔ respectively.
  4. Complete/fix AND test async public Task<PingResult> RunAsync(IEnumerable<string> hostNameOrAddresses, CancellationToken cancellationToken = default) which executes ping for an array of hostNameOrAddresses (which can all be "localhost") in parallel, adding synchronization if needed. ✔
    NOTE:
    • The order of the items in the stdOutput is irrelevant and expected to be intermingled.
    • StdOutput must have all the ping output returned (no lines can be missing) even though intermingled. ✔
  5. Implement AND test public Task<int> RunLongRunningAsync(ProcessStartInfo startInfo, Action<string?>? progressOutput, Action<string?>? progressError, CancellationToken token) using Task.Factory.StartNew() and invoking RunProcessInternal with a TaskCreation value of TaskCreationOptions.LongRunning and a TaskScheduler value of TaskScheduler.Current. Returning a Task<PingResult> is also okay.
    NOTE: This method does NOT use Task.Run. ✔

Extra Credit

  • Test and implement PingProcess.RunAsync(System.IProgress<T> progess) so that you can capture the output as it occurs rather than capturing the output only when the process finishes. ❌

Fundamentals

  • Place all shared project properties into a Directory.Build.Props file. ✔
  • Place all shared project items into a Directory.Build.targets file. ✔
  • Ensure nullable reference types is enabled ✔
  • Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
  • Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ✔
  • and enabled .NET analyzers for both projects ✔
  • For this assignment, consider using Assert.AreEqual<T>() (the generic version) ✔
  • All of the above should be unit tested ✔
  • Choose simplicity over complexity ❌ Code is a bit hard to follow, comments are helpful but clog up flow

Copy link
Collaborator

@Joshua-Lester3 Joshua-Lester3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instructions

  1. Implement PingProcess' public Task<PingResult> RunTaskAsync(string hostNameOrAddress)
    • First implement public void RunTaskAsync_Success() test method to test PingProcess.RunTaskAsync() using "localhost". ✔
    • Do NOT use async/await in this implementation. ✔
  2. Implement PingProcess' async public Task<PingResult> RunAsync(string hostNameOrAddress)
    • First implement the public void RunAsync_UsingTaskReturn_Success() test method to test PingProcess.RunAsync() using "localhost" without using async/await. ✔
    • Also implement the async public Task RunAsync_UsingTpl_Success() test method to test PingProcess.RunAsync() using "localhost" but this time DO using async/await. ✔
  3. Add support for an optional cancellation token to the PingProcess.RunAsync() signature. ✔
    Inside the PingProcess.RunAsync() invoke the token's ThrowIfCancellationRequested() method so an exception is thrown. ✔
    Test that, when cancelled from the test method, the exception thrown is an AggregateException ✔ with a TaskCanceledException inner exception ✔ using the test methods RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrapping ✔and RunAsync_UsingTplWithCancellation_CatchAggregateExceptionWrappingTaskCanceledException ✔ respectively.
  4. Complete/fix AND test async public Task<PingResult> RunAsync(IEnumerable<string> hostNameOrAddresses, CancellationToken cancellationToken = default) which executes ping for an array of hostNameOrAddresses (which can all be "localhost") in parallel, adding synchronization if needed. ✔
    NOTE:
    • The order of the items in the stdOutput is irrelevant and expected to be intermingled.
    • StdOutput must have all the ping output returned (no lines can be missing) even though intermingled. ✔
  5. Implement AND test public Task<int> RunLongRunningAsync(ProcessStartInfo startInfo, Action<string?>? progressOutput, Action<string?>? progressError, CancellationToken token) using Task.Factory.StartNew() and invoking RunProcessInternal with a TaskCreation value of TaskCreationOptions.LongRunning and a TaskScheduler value of TaskScheduler.Current. Returning a Task<PingResult> is also okay. ❌ Did not use Current
    NOTE: This method does NOT use Task.Run.

Extra Credit

  • Test and implement PingProcess.RunAsync(System.IProgress<T> progess) so that you can capture the output as it occurs rather than capturing the output only when the process finishes. ✔

Fundamentals

  • Place all shared project properties into a Directory.Build.Props file.
  • Place all shared project items into a Directory.Build.targets file.
  • Ensure nullable reference types is enabled ✔
  • Ensure that you turn on code analysis for all projects(EnableNETAnalyzers) ✔
  • Set LangVersion and the TargetFramework to the latest released versions available (preview versions optional) ✔
  • and enabled .NET analyzers for both projects ✔
  • For this assignment, consider using Assert.AreEqual<T>() (the generic version) ✔
  • All of the above should be unit tested ✔
  • Choose simplicity over complexity ✔

.gitignore was removed, so sorting through the 435 files with changes was inconvenient.

Comment on lines +57 to +77
public Task<PingResult> RunAsync(string hostNameOrAddress)
{
return RunAsync(hostNameOrAddress, CancellationToken.None);
}

/// <summary>
/// Executes an asynchronous ping operation with cancellation support.
/// </summary>
/// <param name="hostNameOrAddress">The hostname or IP address to ping.</param>
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
/// <returns>A task that represents the asynchronous operation, containing a <see cref="PingResult"/>.</returns>
/// <exception cref="TaskCanceledException">Thrown when the operation is cancelled.</exception>
public Task<PingResult> RunAsync(
string hostNameOrAddress, CancellationToken cancellationToken = default)
{
return Task.Run(() =>
{
cancellationToken.ThrowIfCancellationRequested();
return Run(hostNameOrAddress);
}, cancellationToken);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can be combined, as the token is optional param.

},
cancellationToken,
TaskCreationOptions.LongRunning,
TaskScheduler.Default);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be TaskScheduler.Current


// Task 1: Test RunTaskAsync without async/await
[TestMethod]
[Timeout(10000)] // 10 second timeout
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants