Skip to content

Instantly share code, notes, and snippets.

View drewbourne's full-sized avatar

Drew Bourne drewbourne

View GitHub Profile
@drewbourne
drewbourne / ContextExampleTest.as
Created September 20, 2011 06:03
Context Examples
package example {
public class ContextExampleTest {
private var calculator:Calculator;
private var multiplier:uint;
private function withCalculator():void {
calculator = new Calculator();
}
private function withMultiplier():void {
@drewbourne
drewbourne / DispatchingEvents.as
Created August 8, 2011 23:20
Dispatching Events with Mockolate Mocks
package mockolate.example
{
import flash.events.Event;
import mockolate.mock;
import mockolate.runner.MockolateRule;
import org.flexunit.assertThat;
import org.hamcrest.object.isFalse;
import org.hamcrest.object.isTrue;
ExternalInterface.addCallback("phoneHome", function(value) {
trace("phoneHome", value);
});
ExternalInterface.call("callFlashBackInXSeconds", ExternalInterface.objectID, 3000);
package com.iorad.flexclient.command
{
public class GetUserServiceTest
{
[Rule]
public var mocks:MockolateRule = new MockolateRule();
[Mock]
public var webService:WebService;
@drewbourne
drewbourne / CreateMockolatesManually.as
Created June 21, 2011 03:30
Mockolate FlexUnit Setup Examples
package example
{
import flash.events.Event;
import mockolate.mock;
import mockolate.nice;
import mockolate.prepare;
import org.flexunit.assertThat;
import org.flexunit.async.Async;
@drewbourne
drewbourne / Flash Builder output
Created June 1, 2011 13:21
Broken Flash Builder FlexUnit Stack Trace Error description example
Error: Expected: <0> invocations of namespacedMethod
but: ClassWithNamespaces(proxied).namespacedMethod
at global/assertThatMatcher(assertThatMatcher.as:42)
at global/org.hamcrest::assertThat(assertThat.as:44)
**[ at mockolate.issues.issue42::ExplictlyDefineNamespaceToProxyTest/proxied_shouldNotInterceptProxiedNamespaces(ExplictlyDefineNamespaceToProxyTest.as:25) ]
...removed.
@drewbourne
drewbourne / UsingMockolateForFileReferenceSaveExample.as
Created April 6, 2011 06:34
Example of mocking FileReference for saving a file.
package mockolate.example
{
import flash.events.Event;
import flash.net.FileReference;
import mockolate.mock;
import mockolate.runner.MockolateRunner;
import org.flexunit.async.Async;
@drewbourne
drewbourne / MouseEventKeyboardModifiers.as
Created March 4, 2011 03:27
None of MouseEvent.altKey, ctrlKey or shiftKey work on OS X with FP 10.2
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.MouseEvent;
[SWF(width="500", height="500", backgroundColor="#000000")]
public class MouseEventKeyboardModifiers extends Sprite
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
package org.mockolate.issues
{
import flash.external.ExternalInterface;
public class JSBridge
{
private static var instance:JSBridge;
private static var allowInstantionation:Boolean;
public static function getInstance():JSBridge