This coding challenge is to go over refactoring of code, using tests to ensure the code acts the same as before the refactoring. Also to make the code more manageable and readable, for future generations of developers or yourself if you are unlucky.
- Item quality cannot be less than 0 (Even when passed to the class as less than 0)
- Item quality cannot be more than 50 (Even when passed to the class as more than 50)
- Sulfuras is always 80
These assumptions are a little different to the original code. I would say that the requirements file is more valid for the approach than the existing code. Care would have to be taken rolling this out, as the outputs are slightly different. Picking up errors need to be handled on code refactoring not just making sure the new outputs match the existing outputs 100%.
- Write tests on the existing code (I aligned the test with the requirements sheet)
- Run tests on existing code to make sure it works
- Tests failed, as the outputs do not match the requirements sheet (I made the assumption that it was the source of truth)
- Refactor the code to make it more readable, reliable and improve the formatting
- Rerun the tests to ensure that the new code works as intended