Robotlegs 1.5.2 + SignalCommandMap + FlexUnit + Modular = problems
Hi RL people!
Firstly, i want to thank you for Robotlegs framework. It is
awesome!
But go to my problem...
I am using RL 1.5.2 with Signal extension (SignalCommandMap) and Modular utility. Problem arise when I want to start unit test my app with FlexUnit. As a functional template of unit tests I am using Joel Hooks RL Signal unit tests.
Check code of my test below.
public class ScrollingTests {
private var injector:IInjector;
private var parallaxModel:ParallaxModel;
private var signalCommandMap:ISignalCommandMap;
private var updateParallaxSignal:UpdateParallaxSignal;
[Before]
public function init():void {
injector = new SwiftSuspendersInjector();
parallaxModel = new ParallaxModel();
parallaxModel.width = 2000;
parallaxModel.height = 500;
injector.mapValue(ParallaxModel, parallaxModel);
updateParallaxSignal = new UpdateParallaxSignal();
signalCommandMap = new SignalCommandMap(injector);
}
[After]
public function dispose():void {
injector = null;
signalCommandMap = null;
}
[Test]
public function testParallaxUpdate():void {
signalCommandMap.mapSignal(updateParallaxSignal, UpdateParallaxCommand);
var container:ParallaxScrollContainer = new ParallaxScrollContainer();
updateParallaxSignal.dispatch(container);
}
}
The UpdateParallaxCommand is using this two properties:
[Inject]
public var parallaxScrollContainer:ParallaxScrollContainer;
[Inject]
public var parallax:ParallaxModel;
When I am dispatching Signal that is mapped to UpdateParallaxCommand (which extends SignalCommand which extends Command) in testParallaxUpdate() method then the Injector started to instantiate this command but there is problem that he wants to inject unnecessary command properties that are located in Command class (e.g. contextView) and throws me error: Injector is missing a rule to handle injection into property "contextView" of object "[object UpdateParallaxCommand]".
I do not know whether I am doing something wrong. So, what do you think?
I came across two solutions but I dont like them at all:
1. create clone of real UpdateParallaxCommand which do not extends
Command and test him separately.
2. before test create Context of module but there is problem that I
am unable to intervene context properties because there is no
interface (they are not public for some reason).
Thanks, for your responses.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Stray on 26 Jul, 2012 01:13 PM
The base class 'Command' that you're extending requires the contextView to be injected.
However - if you just have your command implement ICommand instead of extending Command, you shouldn't have that problem.
hth,
Stray
2 Posted by mark.hlavac on 26 Jul, 2012 02:00 PM
I am fool, this is quite simple solution.
Thanks for fast response.
mark.hlavac closed this discussion on 26 Jul, 2012 02:00 PM.