Skip to content

Commit

Permalink
major cleanup of all command related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
creynders committed Apr 11, 2013
1 parent 81c8052 commit 0d686c3
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 344 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
//------------------------------------------------------------------------------
// Copyright (c) 2011 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// Copyright (c) 2009-2013 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//------------------------------------------------------------------------------

package robotlegs.bender.extensions.commandCenter.support
{

public class SelfReportingCallbackCommand
public class ClassReportingCallbackCommand
{

/*============================================================================*/
/* Public Properties */
/*============================================================================*/

[Inject(name="executeCallback")]
public var callback:Function;
[Inject(name="reportingFunction")]
public var reportingFunc:Function;

/*============================================================================*/
/* Public Functions */
/*============================================================================*/

public function execute():void
{
callback(this);
reportingFunc && reportingFunc(ClassReportingCallbackCommand);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// Copyright (c) 2009-2013 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//------------------------------------------------------------------------------

package robotlegs.bender.extensions.commandCenter.support
{

public class ClassReportingCallbackCommand2
{

/*============================================================================*/
/* Public Properties */
/*============================================================================*/

[Inject(name="reportingFunction")]
public var reportingFunc:Function;

/*============================================================================*/
/* Public Functions */
/*============================================================================*/

public function execute():void
{
reportingFunc && reportingFunc(ClassReportingCallbackCommand2);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//------------------------------------------------------------------------------
// Copyright (c) 2009-2013 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//------------------------------------------------------------------------------

package robotlegs.bender.extensions.commandCenter.support
{

public class ClassReportingCallbackGuard
{

/*============================================================================*/
/* Public Properties */
/*============================================================================*/

[Inject(name="reportingFunction")]
public var reportingFunc:Function;

/*============================================================================*/
/* Public Functions */
/*============================================================================*/

public function approve():Boolean
{
reportingFunc && reportingFunc(ClassReportingCallbackGuard);
return true
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// Copyright (c) 2009-2013 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//------------------------------------------------------------------------------

package robotlegs.bender.extensions.commandCenter.support
{

public class ClassReportingCallbackGuard2
{

/*============================================================================*/
/* Public Properties */
/*============================================================================*/

[Inject(name="reportingFunction")]
public var reportingFunc:Function;

/*============================================================================*/
/* Public Functions */
/*============================================================================*/

public function approve():Boolean
{
reportingFunc && reportingFunc(ClassReportingCallbackGuard2);
return true
}
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
//------------------------------------------------------------------------------
// Copyright (c) 2011 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// Copyright (c) 2009-2013 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//------------------------------------------------------------------------------

package robotlegs.bender.extensions.commandCenter.support
{

public class SelfReportingCallbackHook
public class ClassReportingCallbackHook
{

/*============================================================================*/
/* Public Properties */
/*============================================================================*/

[Inject]
public var command:SelfReportingCallbackCommand;

[Inject(name="hookCallback")]
public var callback:Function;
[Inject(name="reportingFunction")]
public var reportingFunc:Function;

/*============================================================================*/
/* Public Functions */
/*============================================================================*/

public function hook():void
{
callback(this);
reportingFunc && reportingFunc(ClassReportingCallbackHook);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
package robotlegs.bender.extensions.directCommandMap.impl
{
import org.hamcrest.assertThat;
import org.hamcrest.collection.array;
import org.hamcrest.core.not;
import org.hamcrest.object.equalTo;
import org.hamcrest.object.instanceOf;
import org.hamcrest.object.isTrue;
import org.hamcrest.object.strictlyEqualTo;
import org.swiftsuspenders.Injector;
import robotlegs.bender.extensions.commandCenter.impl.CommandPayload;
import robotlegs.bender.extensions.commandCenter.support.CallbackCommand;
import robotlegs.bender.extensions.commandCenter.support.CallbackCommand2;
import robotlegs.bender.extensions.commandCenter.support.NullCommand;
Expand Down Expand Up @@ -111,21 +109,6 @@ package robotlegs.bender.extensions.directCommandMap.impl
assertThat(actual, not(equalTo(subject)));
}

[Test]
public function injects_payload_into_command():void
{
const actual:Array = [];
const expected:Array = ['string', 5];
var payload:CommandPayload = new CommandPayload(expected, [String, int]);
injector.map(Function, 'reportingFunction').toValue(function(passed:Object):void {
actual.push(passed);
});

subject.map(PayloadReportingCommand).execute(payload);

assertThat(actual, array(expected));
}

[Test]
public function detains_command():void
{
Expand Down Expand Up @@ -175,33 +158,6 @@ package robotlegs.bender.extensions.directCommandMap.impl

import robotlegs.bender.extensions.directCommandMap.api.IDirectCommandMap;

internal class PayloadReportingCommand
{

/*============================================================================*/
/* Public Properties */
/*============================================================================*/

[Inject]
public var message:String;

[Inject]
public var code:int;

[Inject(name="reportingFunction")]
public var reportingFunc:Function;

/*============================================================================*/
/* Public Functions */
/*============================================================================*/

public function execute():void
{
reportingFunc(message);
reportingFunc(code);
}
}

internal class DirectCommandMapReportingCommand
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package robotlegs.bender.extensions.directCommandMap.impl
import mockolate.capture;
import mockolate.ingredients.Capture;
import mockolate.mock;
import mockolate.received;
import mockolate.runner.MockolateRule;
import mockolate.stub;
import org.hamcrest.assertThat;
Expand All @@ -24,13 +23,10 @@ package robotlegs.bender.extensions.directCommandMap.impl
import robotlegs.bender.extensions.commandCenter.api.ICommandExecutor;
import robotlegs.bender.extensions.commandCenter.api.ICommandMapping;
import robotlegs.bender.extensions.commandCenter.api.ICommandMappingList;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandConfigurator;
import robotlegs.bender.extensions.commandCenter.impl.CommandPayload;
import robotlegs.bender.extensions.commandCenter.support.ClassReportingCallbackHook;
import robotlegs.bender.extensions.commandCenter.support.NullCommand;
import robotlegs.bender.extensions.commandCenter.support.NullCommand2;
import robotlegs.bender.extensions.commandCenter.support.SelfReportingCallbackHook;
import robotlegs.bender.extensions.directCommandMap.dsl.IDirectCommandConfigurator;
import robotlegs.bender.extensions.directCommandMap.dsl.IDirectCommandMapper;
import robotlegs.bender.framework.impl.guardSupport.GrumpyGuard;
import robotlegs.bender.framework.impl.guardSupport.HappyGuard;

Expand Down Expand Up @@ -114,7 +110,7 @@ package robotlegs.bender.extensions.directCommandMap.impl
[Test]
public function withHooks_sets_hooks_of_mapping():void
{
var expected:Array = [SelfReportingCallbackHook, SelfReportingCallbackHook];
var expected:Array = [ClassReportingCallbackHook, ClassReportingCallbackHook];

createMapper(NullCommand).withHooks.apply(null, expected);

Expand Down
Loading

0 comments on commit 0d686c3

Please sign in to comment.