Create a unit test for the VolunteerManager mobile application. Specifically, your unit test will test the VolunteerManager structure.
- The structure can be initialized without parameters (i.e.,
VolunteerManager()) - The structure provides a
volunteermethod that provides the volunteer's name (String) and the hours (Int) to volunteer using theforargument. Here is an example for calling the function:
manager.volunteer("Paul", for: 4)- If the volunteer's name is not yet in the dictionary, it should create a new entry in the dictionary and provide the given hours. However, if the hours is less than 0 then it should not add the volunteer at all. If the hours provided is over 20, then it should be changed to 20 (i.e., 30 -> 20).
- If the volunteer's name already exists in the dictionary, it should add the given hours to the previously set hours. For example, if Paul was assigned 4 hours and volunteers for 3 more, then their hours should show 7. When time is added and the volunteer's time goes over 20, then it should be changed to 20. For example, if Paul already has 15 hours and 10 hours is added, then it should be changed to 20 (instead of 25). If the added hours is negative, the hours should not be updated.
- Create your unit tests inside VolunteerManagerTests/VolunteerManagerTests.swift.
- Your unit tests must test all expected behaviors of the
VolunteerManagerstructure. - Run your unit test. Expect your unit tests to fail because there are bugs in the structure.
- Use your unit test results to identify and fix the bugs in the
VolunteerManagerstructure. - Run the program to see it in action!
Hint: You can look at your test's code coverage to help you figure out if you have fully tested the VolunteerManager structure. You need to fix three bugs.