-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/update assessment instructions #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ctions for candidate. Also added advanced tests cases the interviewer can use for checking edge cases or common defects
There was a problem hiding this 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: |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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".
| - Witholding groups are applied using the following order: | |
| - Withholding groups are applied using the following order: |
|
|
||
| Start Debug: `F5` | ||
|
|
||
| ### Commmand-line |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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".
| ### Commmand-line | |
| ### Command-line |
| @@ -1,13 +1,223 @@ | |||
| namespace GrossToNet; | |||
| using System.Text; | |||
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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.
| using System.Text; |
| /// Whether this deduction is applied before taxes (pre-tax) or after (post-tax) | ||
| /// </summary> | ||
| public required bool IsPreTax { get; set; } | ||
|
|
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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).
|
|
||
| if (testCases == null || !testCases.Any()) | ||
| { | ||
| throw new Exception("Failed to load payroll data from input.json"); |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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.
| throw new Exception("Failed to load payroll data from input.json"); | |
| throw new Exception($"Failed to load payroll data from {testFile}"); |
| Environment.Exit(1); | ||
| } | ||
|
|
||
| Console.WriteLine($"Loading " + testFile + $" from: {filePath}"); |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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.
| Console.WriteLine($"Loading " + testFile + $" from: {filePath}"); | |
| Console.WriteLine($"Loading {testFile} from: {filePath}"); |
| ### 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: |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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".
| ### 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: |
| 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; | ||
| } |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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.
| 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!; |
| </Content> | ||
| </ItemGroup> | ||
| </Project> | ||
| </ItemGroup> |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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.
| </ItemGroup> | |
| </ItemGroup> |
| ### Deductions | ||
|
|
||
| - Types: `flat`, `percentage` | ||
| - Flat decductions have a fixed dollar `value` |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
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".
| - Flat decductions have a fixed dollar `value` | |
| - Flat deductions have a fixed dollar `value` |
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.