.NET Core Tech Test - From a Previous Life
Overview
"From a Previous Life" our software development technology moves so fast each year that this definitely counts as a previous life (in tech years that is - 4.5 years ago as of Dec 2023)
About 4.5 years ago I was asked to complete a .NET Tech Test as part of a .NET contract job interview process for a well known national gym company. This was done in .NET Core 2.1.
The company allowed the test to be done in your own time and you could code as much as you wanted for the solution to the test. I prefer this method as it allows you to work as you normally would and not be under pressure to complete the test in a short interview time frame which doesn't gauge a candidate IMHO.
My test solution was well received and I was offered a contract position with the company however my circumstances changed with another role and I was unable to take up the position.
I recently came across the test and thought it would be interesting to put here for reference as I know it is no longer being used as an interview test and thought I might look at refactoring it in .NET 8.0 as a future exercise.
The test was based around an e-commerce shopping basket scenario with a number of involved requirements around applying different types of discount vouchers to a shopping basket.
The solution I provided to the test is located in Github here.
Below are the details of the tech test.
Tech Test Question - Ecommerce Shopping Basket
Scenario A company issues two types of voucher for customers to gain discounts on shopping baskets.
Gift Voucher
- Can be redeemed against the value of a basket.
- Multiple gift vouchers can be applied to a basket.
Offer vouchers
- Have a threshold that needs to be matched or exceeded before a discount can be applied e.g. £5.00 off of baskets totalling £50
- Only a single offer voucher can be applied to a basket.
- Maybe applicable to only a subset of products.
Functionality / Business Logic
- Offer and Gift vouchers can be used in conjunction.
- If a customer applies an offer voucher to a basket that will not satisfy the threshold or a customer removes item/changes an items quantity resulting in a voucher not being a message will need to be displayed to the customer.
- Gift vouchers can only be redeemed against non gift voucher products and purchase of gift vouchers do no contribute to discountable basket total.
Task
- You need not create a UI for this application.
- Write an application that represents a basket and has the ability to handle the following scenarios:
Basket 1
1 Hat @ £10.50
1 Jumper @ £54.65
-------------
1 x £5.00 Gift Voucher XXX-XXX applied
-------------
Total: £60.15
-------------
Basket 2
1 Hat @ £25.00
1 Jumper @ £26.00
-------------
1 x £5.00 off Head Gear in baskets over £50.00 Offer Voucher YYY-YYY applied
-------------
Total: £51.00
-------------
Message: “There are no products in your basket applicable to voucher Voucher YYY-YYY .”
Basket 3
1 Hat @ £25.00
1 Jumper @ £26.00
1 Head Light (Head Gear Category of Product) @ £3.50
-------------
1 x £5.00 off Head Gear in baskets over £50.00 Offer Voucher YYY-YYY applied
-------------
Total: £51.00
-------------
Basket 4
1 Hat @ £25.00
1 Jumper @ £26.00
-------------
1 x £5.00 Gift Voucher XXX-XXX applied
1 x £5.00 off baskets over £50.00 Offer Voucher YYY-YYY applied
-------------
Total: £41.00
-------------
Basket 5
1 Hat @ £25.00
1 £30 Gift Voucher @ £30.00
-------------
1 x £5.00 off baskets over £50.00 Offer Voucher YYY-YYY applied
-------------
Total: £55.00
-------------
Message: “You have not reached the spend threshold for voucher YYY-YYY. Spend another £25.01 to receive £5.00 discount from your basket total.”
Tech Test Solution
The solution I came up with is located in Github here.
The solution I created used the following design patterns:
- decorator
- factory
- strategy
- specification
Some unit tests as I iterated on the design are located here.
There was also a separate console app created to display the 5 baskets cases visually which is located here.