Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating initial unit tests for each class #36

Open
wants to merge 11 commits into
base: master
from

Cleaning up CameraQualityCommandTest (I think...)

  • Loading branch information...
Adam-Sharpe committed Sep 15, 2014
commit ac562927e8bedea9746970df3b1a2162ae189165
@@ -2,6 +2,7 @@ package org.bigbluebutton.command
{
import flash.events.Event;

import mockolate.nice;
import mockolate.prepare;
import mockolate.received;
import mockolate.runner.MockolateRule;
@@ -21,20 +22,15 @@ package org.bigbluebutton.command
[Rule]
public var mockolateRule:MockolateRule = new MockolateRule();

[Mock]
public var videoConnection:VideoConnection;

[Mock]
public var userSession:UserSession;

private static var TIMEOUT:Number = 5000;

protected var instance:CameraQualityCommand;

[Before(async)]
public function setUp():void
{
Async.proceedOnEvent(this, prepare(VideoConnection), Event.COMPLETE, TIMEOUT, timeoutHandler);
Async.proceedOnEvent(this, prepare(VideoConnection), Event.COMPLETE);
instance = new CameraQualityCommand();
instance.userSession = userSession;
}
@@ -60,34 +56,22 @@ package org.bigbluebutton.command
[Test]
public function executed_callsSelectCameraQualityMethod():void
{
// arrange
stub(instance.userSession).getter("videoConnection").returns(videoConnection);

// act
var videoConnection:VideoConnection = nice(VideoConnection);
stub(userSession).getter("videoConnection").returns(videoConnection);
instance.execute();

// assert
assertThat(instance.userSession.videoConnection, received().method('selectCameraQuality'));
}

[Test]
public function executed_callsSelectCameraQualityMethodWithCorrectArgs():void
{
// arrange
var videoConnection:VideoConnection = nice(VideoConnection);
instance.cameraQualitySelected = 2;
instance.userSession = userSession;
stub(instance.userSession).getter("videoConnection").returns(videoConnection);

// act
stub(userSession).getter("videoConnection").returns(videoConnection);
instance.execute();

// assert
assertThat(instance.userSession.videoConnection, received().method('selectCameraQuality').arg(2));
}

protected function timeoutHandler(passThroughData:Object):void
{
fail("Timeout occured during setUp() method");
}

}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.