Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New abstract rate strategy #3

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

tuf65651
Copy link

No description provided.

kmbosworth321 and others added 24 commits September 19, 2018 11:58
Implement emptyReturnsTotalEntered test to check if paystation.empty() method returns total amount entered. 

currently RED (test fails)
Test should have expected value of 10
- Add to interface
- Add to Impl
- Ensure returns total inserted so far

makes emptyReturnsTotalEntered() test GREEN
Add test case to ensure cancel method does not include any coins in a cancelled transaction when it returns the total value.

Test is RED
I'm the worst
Access modifiers (public, private, etc.) in interfaces are redundant.
From void to Map<Integer, Integer>. Also return the appropriate typed object in implementation so that build does not fail.
insertedMap is a HashMap<Integer, Integer> recording the coin types and their respective quantities entered.
To reflect change in return type.
In 'cancel,' supposed to make a deep copy of the insertedMap but made a shallow copy instead. This fixes that.
Into two separate tests: shouldClearAfterCancel and shouldClearMapAfterCancel, to match requirements.
Empty is dependent on buy(). Without a call to buy(), the coin amounts are not collected. These rewrite addresses that requirement.

Tests are now RED.
Add totalCollected which only accrues value after a call to buy() as per requirements. 
Reset totalCollected after call to empty().

Both tests written for empty() are now GREEN.
Add emptyResetsTotalCollected() test. Temporarily comment out totalCollected set to 0 in empty() in Impl to demonstrate test in fail state.

Test is currently RED.
Uncomment relevant line to fix test.

Test is now GREEN.
Add test to check that map of coins is cleared after a call to buy().  Comment out code in Impl to demonstrate fail state.

Test is currently RED.
Reimplement insertedMap.clear() inside reset() method of Impl to clear map after call to cancel() or buy()

Test is now GREEN
Test cases: No money, base case, 10 cents, into second hour, into third hour.
@tuf65651
Copy link
Author

My last tests assumed a constructor for Pay Station that takes Rate Strategy as a parameter. I see that this might not be the best say to configure an instance's default. If we never implement that constructor, just implement the instance method to set rate strategy and I'll make the test use that instead.

Test cases: No money, base case, 10 cents, into second hour, into third hour.
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.

3 participants