Skip to content

Conversation

@ShawnDigital
Copy link

Added a lot of boilerplate grunt work like models, file processing, running tests cases which was not beneficial to the assessment. This should allow them to focus on the primary problem being solved.

…ctions for candidate.

Also added advanced tests cases the interviewer can use for checking edge cases or common defects
Copilot AI review requested due to automatic review settings December 8, 2025 14:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors a coding assessment for a gross-to-net payroll calculator by providing boilerplate code (models, file processing, test harness) so candidates can focus on implementing the core calculation logic in the PayrollCalculator.Calculate method.

Key changes include:

  • Removed manual file processing requirements by adding pre-built model classes and test infrastructure
  • Replaced basic input files with a comprehensive test harness that automatically validates expected vs actual results
  • Updated documentation to clarify requirements and provide clear instructions for running tests

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
gross-to-net/test-cases.json Removed old test cases file from root directory
gross-to-net/input.json Removed old input file from root directory
gross-to-net/dotnet/test-cases.json Added new comprehensive test cases with 10 scenarios covering various payroll scenarios
gross-to-net/dotnet/models/Withholding.cs Added model class representing withholding entries (taxes/deductions)
gross-to-net/dotnet/models/Tax.cs Added model class for tax calculations with support for percentage and capped percentage types
gross-to-net/dotnet/models/PayrollResult.cs Added model class for calculation results containing gross pay, taxable earnings, withholdings, and net pay
gross-to-net/dotnet/models/Earning.cs Added model class for earnings supporting both hourly and salary types
gross-to-net/dotnet/models/Deduction.cs Added model class for deductions with flat and percentage types, pre-tax and post-tax support
gross-to-net/dotnet/Program.cs Completely rewrote to provide automated test runner with validation, error reporting, and help text
gross-to-net/dotnet/PayrollCalculator.cs Added stub implementation with TODO for candidates to complete
gross-to-net/dotnet/GrossToNet.csproj Updated to reference new test-cases.json file instead of old input.json
gross-to-net/directory-structure.txt Added documentation showing the project structure
gross-to-net/README.md Rewrote with clearer requirements, calculation formulas, and instructions for building/running tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


- Types: `tax`, `deductions`
- Deductions are either Pre-Tax or Post-Tax depending on the `isPrefix` value.
- Witholding groups are applied using the following order:
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Spelling error: "Witholding" should be "Withholding".

Suggested change
- Witholding groups are applied using the following order:
- Withholding groups are applied using the following order:

Copilot uses AI. Check for mistakes.

Start Debug: `F5`

### Commmand-line
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Spelling error: "Commmand-line" has an extra 'm' and should be "Command-line".

Suggested change
### Commmand-line
### Command-line

Copilot uses AI. Check for mistakes.
@@ -1,13 +1,223 @@
namespace GrossToNet;
using System.Text;
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Unused import: System.Text is imported but not used anywhere in the code.

Suggested change
using System.Text;

Copilot uses AI. Check for mistakes.
/// Whether this deduction is applied before taxes (pre-tax) or after (post-tax)
/// </summary>
public required bool IsPreTax { get; set; }

Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

[nitpick] Unnecessary blank line before closing brace. While not incorrect, it's inconsistent with other model classes in the same PR (e.g., Withholding.cs, Tax.cs, PayrollResult.cs, Earning.cs don't have this blank line).

Suggested change

Copilot uses AI. Check for mistakes.

if (testCases == null || !testCases.Any())
{
throw new Exception("Failed to load payroll data from input.json");
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Misleading error message: The error message references "input.json" but the code is actually loading from a test cases file (either "test-cases.json" or "advanced-test-cases.json" or a custom file). The error message should reference the actual file being loaded.

Suggested change
throw new Exception("Failed to load payroll data from input.json");
throw new Exception($"Failed to load payroll data from {testFile}");

Copilot uses AI. Check for mistakes.
Environment.Exit(1);
}

Console.WriteLine($"Loading " + testFile + $" from: {filePath}");
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

[nitpick] String concatenation readability: The expression "Loading " + testFile + $" from: {filePath}" mixes string concatenation and interpolation. Consider using consistent string interpolation: $"Loading {testFile} from: {filePath}" for better readability.

Suggested change
Console.WriteLine($"Loading " + testFile + $" from: {filePath}");
Console.WriteLine($"Loading {testFile} from: {filePath}");

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +36
### Witholdings

- Types: `tax`, `deductions`
- Deductions are either Pre-Tax or Post-Tax depending on the `isPrefix` value.
- Witholding groups are applied using the following order:
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Spelling error: "Witholdings" should be "Withholdings".

Suggested change
### Witholdings
- Types: `tax`, `deductions`
- Deductions are either Pre-Tax or Post-Tax depending on the `isPrefix` value.
- Witholding groups are applied using the following order:
### Withholdings
- Types: `tax`, `deductions`
- Deductions are either Pre-Tax or Post-Tax depending on the `isPrefix` value.
- Withholding groups are applied using the following order:

Copilot uses AI. Check for mistakes.
Comment on lines +125 to +133
var actual = testCase.ActualOutput!;

if (testCase.Passed == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"\t ✗ Test failed: {testCase.Description} --> {(testCase.Error != null ? $"{testCase.Error.GetType().Name} --> " : string.Empty)}{testCase.Message}");
Console.ResetColor();
return;
}
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Potential null reference exception: testCase.ActualOutput could be null if an exception was thrown during calculation (lines 91-102), but it's being dereferenced here without a null check. This will cause a NullReferenceException when the test runner tries to validate a failed test case.

Suggested change
var actual = testCase.ActualOutput!;
if (testCase.Passed == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"\t ✗ Test failed: {testCase.Description} --> {(testCase.Error != null ? $"{testCase.Error.GetType().Name} --> " : string.Empty)}{testCase.Message}");
Console.ResetColor();
return;
}
if (testCase.ActualOutput == null)
{
testCase.Passed = false;
testCase.Message = "No actual output produced for test case.";
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"\t ✗ Test failed: {testCase.Description} --> No actual output produced.");
Console.ResetColor();
return;
}
var actual = testCase.ActualOutput!;

Copilot uses AI. Check for mistakes.
</Content>
</ItemGroup>
</Project>
</ItemGroup>
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent indentation: The closing </ItemGroup> tag has inconsistent indentation compared to line 11. It should align with the opening tag.

Suggested change
</ItemGroup>
</ItemGroup>

Copilot uses AI. Check for mistakes.
### Deductions

- Types: `flat`, `percentage`
- Flat decductions have a fixed dollar `value`
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Spelling error: "decductions" should be "deductions".

Suggested change
- Flat decductions have a fixed dollar `value`
- Flat deductions have a fixed dollar `value`

Copilot uses AI. Check for mistakes.
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.

2 participants