Skip to content

Conversation

@NickelTing
Copy link

@NickelTing NickelTing commented Nov 6, 2025

Refactored the code via:

  • Creating Booleans for criteria
  • Enable type checks to catch variable type errors earlier
  • Avoiding nesting by using if else statements as less as possible
  • Extract repetitive code in to methods for reusability and easier future improvement.
  • Also fix some bugs in the code, for example, not including tax amount for standard invoice.

Also made some changes to the test to accommodate the latest NUnit framework. Recommend download Microsoft.Net.Test.Sdk 18.0.0 and run dotnet run. Alternatively, you can use Microsoft Visual Studio, download NUnit framework and NUnit3TestAdapters packages, and run it in test explorer. I refactored the code and ran the tests on Visual Studio.

Spent around one hour on refactoring code and another hour on setting up dependencies and modifying tests.

Please do not hestitate to ask me anything about my refactoring. Once again many thanks for the opportunity.

refactor the code by creating Booleans for criteria, promote type checks to catch variable type errors earlier, avoiding nesting by using if else statements as less as possible, and extract repetitive code in to methods for reusability and easier future improvement. Also made some changes to the test to accommodate the latest Nunit framework.
@NickelTing
Copy link
Author

Just realised I didn't push the necessary packages for testing due to GitHub issues. Please make sure you have the following packages installed in your local machine:

  • Microsoft.Net.Test.Sdk 18.0.0
  • NUnit (framework) 4.4.0
  • NUnit3Adapter 5.2.0

Run dotnet build to build the project, then dotnet test to run the tests inside the project.

Once again please contact me if you have further questions.

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.

1 participant