Skip to content
Browse files

added ability to name Mock instances to aid debugging, and Mock.toStr…

…ing()

git-svn-id: https://mock-as3.googlecode.com/svn/trunk@26 bb1cc804-513f-0410-8659-4d20a89a40e2
  • Loading branch information...
1 parent 36680d3 commit 61a5bbb636b0ce683f1ebe1ac6c31d8981f97038 firstbourne committed Oct 13, 2009
Showing with 9 additions and 3 deletions.
  1. +9 −3 core/src/com/anywebcam/mock/Mock.as
View
12 core/src/com/anywebcam/mock/Mock.as
@@ -115,14 +115,15 @@ package com.anywebcam.mock
* @param target The target that is delegating calls to this Mock
* @param ignoreMissing Indicates whether methods and properties without expectations are ignored
*/
- public function Mock( target:Object = null, ignoreMissing:Boolean = false )
+ public function Mock( target:Object = null, ignoreMissing:Boolean = false, name:String=null )
{
_target = target;
_expectations = [];
_ignoreMissing = ignoreMissing || false;
_currentOrderNumber = 0;
_orderedExpectations = [];
_eventDispatcher = new EventDispatcher(this);
+ _name = name;
}
private var _target:Object;
@@ -202,12 +203,17 @@ package com.anywebcam.mock
private var _orderedExpectations:Array;
/**
+ * Name of this Mock
+ */
+ private var _name:String;
+
+ /**
* String representation of this Mock
*/
public function toString():String
{
var className:String = getQualifiedClassName( target );
- return className.slice( className.lastIndexOf(':') + 1 );
+ return (_name ? "("+ _name +")" : "") + className.slice( className.lastIndexOf(':') + 1 );
}
/**
@@ -240,7 +246,7 @@ package com.anywebcam.mock
*/
public function method( methodName:String ):MockExpectation
{
- return expect().method( methodName );
+ return expect().method( methodName );
}
/**

0 comments on commit 61a5bbb

Please sign in to comment.
Something went wrong with that request. Please try again.