There are five types:
- Dummy
- Stub
- Spy
- Mock
- Fake
| function RPS(){ | |
| this.play = function(p1, p2, ui){ | |
| new PlayUseCase(p1, p2, ui).execute() | |
| } | |
| } | |
| function PlayUseCase(p1, p2, ui){ | |
| this.execute = function(){ | |
| if (inputInvalid()){ | |
| ui.invalid() |
| //old school es5 syntax for creating a class | |
| //advantage: lets you create private functions and state through closure | |
| //disadvantage: looks weird if you learned OO through language like c++/java/ruby, etc. Doesn't support prototypical inheritance. | |
| //constructor function | |
| function MyES5Class(aPrivateVar){ | |
| var aontherPrivateVar = "I'm a private variable! You can't access me from the outside." | |
| this.publicVar = "I'm a public variable! You can access me from the outside!" | |
| this.myPublicFunction = function(){ |