package mypackage
{

	import org.flexunit.rules.IMethodRule;
	import org.mockito.integrations.eq;
	import org.mockito.integrations.flexunit4.MockitoRule;
	import org.mockito.integrations.given;
	import org.mockito.integrations.verify;
	import org.mockito.integrations.atLeast;
	import org.mockito.integrations.never;

	[Mock(type="anotherPackage.ISomeService")]


	public class ReEvaluateAvailableFiltersCommandTest
	{
		[Rule]
		public var rule:IMethodRule = new MockitoRule();

		[Before]
		public function setUp():void
		{
			_sut = new MyCommand();
			_someService = MockServiceFactory.getSomeService();         <- In here it might put the _someService behind a facade that MyCommand uses
			

		}

		[After]
		public function tearDown():void
		{
			_sut = null;
			_someService = null;
			MockServiceFactory.tearDown();
		}

		[Test]
		public function nameOfMyFirstTest():void
		{
		    //given

			given(_someService.doThis()).willReturn("this");
			given(_someService.doThat()).willReturn("that");           <- This creates a dictionary for a given method call then X value is returned

		    //when
			_sut.execute(null);

		    //then
			verify().that( _someService.doThis(eq("this")));
		}

		[Test]
		public function anotherTestHere():void
		{
			//given

			//when

			//then
			
		}
		
		private var _sut: MyCommand;

		private var _someService:ISomeService;

	}
}




The factory looks like this

package mypackage
{

	public class MockServiceFactory
	{
                public static function getSomeService():ISomeService
		{
			var someService:ISomeService = mock(ISomeService);
			SharedServices.iskill_ui_privileged::setSomeService(someService);
			return someService;
		}
              
                public static function deleteSomeService():void
		{
                        SharedServices.iskill_ui_privileged::setSomeService(null);
		}
		
		public static function tearDown() : void
		{
			deleteSomeService();
                }
          

        }

}


 


The facade looks like this



package somepackage.shared
{
	

	public class SharedServices
	{
		protected static var _someService;

		////////////////////////////////////////////////////////////
		// UI Services
		////////////////////////////////////////////////////////////

		private static function getSomeService():SomeService {  
                     return _someService; 
                }
		
		////////////////////////////////////////////////////////////
		// set
		////////////////////////////////////////////////////////////
		
		iskill_ui_privileged static function setSomeService ( value : SomeService ) : void
		{
			_someService = value;
		}