Last active
August 29, 2015 14:01
-
-
Save objarni/8c9755f2a5671b9de930 to your computer and use it in GitHub Desktop.
Zoo DDD tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rule 1. Carnivors and herbivors cannot live together. | |
# For example, moving a lion to an enclosement with a zebra is not good, since the zebra will be eaten. | |
zoo = Zoo() | |
zoo.add_fenced_enclosure('Fenced area 1') | |
zoo.add_fenced_enclosure('Fenced area 2') | |
zoo.add_carnivore('lion', 'Fenced area 1') | |
zoo.add_herbivore('zebra', 'Fenced area 2') | |
assertThrows(zoo.move_animal('lion', 'Fenced area 2')) | |
# Rule 2: Herbivors can live side-by-side. | |
# Moving a giraffe to the enclosement of an elephant is OK, since both species are herbivors and wont kill each other. | |
zoo = Zoo() | |
zoo.add_fenced_enclosure('Fenced area 1') | |
zoo.add_fenced_enclosure('Fenced area 2') | |
zoo.add_herbivore('giraffe', 'Fenced area 1') | |
zoo.add_herbivore('elephant', 'Fenced area 2') | |
zoo.move_animal('giraffe', 'Fenced area 2') | |
verify_domain_event('animal moved', {animal:'giraffe', enclosement:'Fenced area 2'}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment