Skip to content

Instantly share code, notes, and snippets.

@drewbourne
Created March 3, 2011 23:36
Show Gist options
  • Save drewbourne/853862 to your computer and use it in GitHub Desktop.
Save drewbourne/853862 to your computer and use it in GitHub Desktop.
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