Overview
In this challenge, you are tasked with restructuring an existing application that is based around the members of a library. The app has a Member class that caters for two kinds of library member, junior and adult. Junior members are under 16 years of age. Adult members are allowed to borrow any book from the library, whilst junior members can only borrow books from the ‘Child’ category. In its current state, the ‘LendingLibrary’ project has a single class called ‘Member’ that contains three methods called ‘Borrow’, ‘PayFine’, and ‘NewFine’.
The Visual Studio solution has a console app project called ‘LendingLibraryUI’ and a unit test project called ‘LendingLibraryTests’. Both projects contain similar logic that tests the LendingLibrary project’s underlying functionality with four members called ‘pippiNoFine’ and ‘cruellaWithFine’ (both junior members), and ‘georgeNoFine’ and ‘dracoWithFine’ (adult members).
Your job is to reengineer the logic so that the ‘Borrow’ method of the Member class raises an exception if the selected book is not suitable for children and the member is under 16. You are also expected to add an XUnit test project to the solution and add a set of unit tests that ensure your enhancement works in all situations.
Note: The Visual Studio starter solution already includes an XUnit test project, but this only includes tests for other features.
Note: Upon submission, the output of your code will be automatically tested. Please recognise the tests are looking for precisely sequenced sets of text so do not alter the student data in any way. Also, if you think your code is producing the correct output but the associated test fails, then it’s quite likely there’s some kind of minor discrepancy such as an additional or missing space or piece of punctuation.