Created
March 3, 2011 23:36
-
-
Save drewbourne/853862 to your computer and use it in GitHub Desktop.
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
package org.mockolate.issues | |
{ | |
import flash.events.Event; | |
import flash.events.IEventDispatcher; | |
import mockolate.ingredients.Sequence; | |
import mockolate.runner.MockolateRule; | |
import mockolate.sequence; | |
public class SequencingExample | |
{ | |
[Rule] | |
public var mocks:MockolateRule = new MockolateRule(); | |
[Mock] | |
public var dispatcher:IEventDispatcher; | |
[Test] | |
public function sequencingExample_executedInOrder_shouldPass():void | |
{ | |
var s:Sequence = sequence(); | |
mocks.mock(dispatcher).method("addEventListener").anyArgs().once().ordered(s); | |
mocks.mock(dispatcher).method("dispatchEvent").anyArgs().once().ordered(s); | |
dispatcher.addEventListener(Event.COMPLETE, function():void | |
{ | |
}); | |
dispatcher.dispatchEvent(new Event(Event.COMPLETE)); | |
} | |
[Test(verify="false")] | |
public function sequencingExample_executedInOutOfOrder_shouldFail():void | |
{ | |
var s:Sequence = sequence(); | |
mocks.mock(dispatcher).method("addEventListener").anyArgs().once().ordered(s); | |
mocks.mock(dispatcher).method("dispatchEvent").anyArgs().once().ordered(s); | |
dispatcher.dispatchEvent(new Event(Event.COMPLETE)); | |
dispatcher.addEventListener(Event.COMPLETE, function():void | |
{ | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment