Created
June 21, 2011 03:30
-
-
Save drewbourne/1037188 to your computer and use it in GitHub Desktop.
Mockolate FlexUnit Setup Examples
This file contains 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
package example | |
{ | |
import flash.events.Event; | |
import mockolate.mock; | |
import mockolate.nice; | |
import mockolate.prepare; | |
import org.flexunit.assertThat; | |
import org.flexunit.async.Async; | |
import org.hamcrest.object.isTrue; | |
public class CreateMockolatesManually | |
{ | |
public var myClass:MyClass; | |
[Before(async, order=1)] | |
public function prepareMockClasses():void | |
{ | |
Async.proceedOnEvent(this, prepare(MyClass), Event.COMPLETE); | |
} | |
[Before(order=2)] | |
public function setup():void | |
{ | |
myClass = nice(MyClass); | |
} | |
[Test] | |
public function myClass_shouldDoSomething():void | |
{ | |
mock(myClass).method("doSomething").returns(true); | |
assertThat(myClass.doSomething(), isTrue()); | |
} | |
} | |
} |
This file contains 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
package example | |
{ | |
import mockolate.mock; | |
import mockolate.runner.MockolateRule; | |
import org.flexunit.assertThat; | |
import org.hamcrest.object.isTrue; | |
public class CreateMockolatesUsingRule | |
{ | |
[Rule] | |
public var mocks:MockolateRule = new MockolateRule(); | |
[Mock] | |
public var myClass:MyClass; | |
[Test] | |
public function myClass_shouldDoSomething():void | |
{ | |
mock(myClass).method("doSomething").returns(true); | |
assertThat(myClass.doSomething(), isTrue()); | |
} | |
} | |
} |
This file contains 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
package example | |
{ | |
import mockolate.mock; | |
import mockolate.runner.MockolateRunner; | |
import org.flexunit.assertThat; | |
import org.hamcrest.object.isTrue; | |
MockolateRunner; | |
[RunWith("mockolate.runner.MockolateRunner")] | |
public class CreateMockolatesUsingRunner | |
{ | |
[Mock] | |
public var myClass:MyClass; | |
[Test] | |
public function myClass_shouldDoSomething():void | |
{ | |
mock(myClass).method("doSomething").returns(true); | |
assertThat(myClass.doSomething(), isTrue()); | |
} | |
} | |
} |
This file contains 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
package example | |
{ | |
public class MyClass | |
{ | |
public function MyClass() | |
{ | |
super(); | |
} | |
public function doSomething():Boolean | |
{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment