IUIEActivationProcess CreateNewProcess(bool activates) { IUIEActivationProcess newProcess; switch (thisActivationMode) { case ActivationMode.None: newProcess = thisProcessFactory.CreateNonActivatorUIEActivationProcess( this, activates, thisActivationProcessTime ); break; case ActivationMode.Alpha: newProcess = thisProcessFactory.CreateAlphaActivatorUIEActivationProcess( thisUIElement, this, activates, thisActivationProcessTime ); break; default: newProcess = null; break; } return(newProcess); }
public void StartNewActivationProcess_ActivationModeIsAlpha_SwtchesProcessProperly() { ITestUIEActivationStateEngineConstArg arg = CreateMockConstArg(); arg.activationMode.Returns(ActivationMode.Alpha); TestUIEActivationStateEngine engine = new TestUIEActivationStateEngine(arg); IUISystemProcessFactory procFactory = arg.processFactory; IAlphaActivatorUIEActivationProcess process = Substitute.For <IAlphaActivatorUIEActivationProcess>(); procFactory.CreateAlphaActivatorUIEActivationProcess(arg.uiElement, engine, true).Returns(process); IUIEActivationProcess prevProcess = Substitute.For <IUIEActivationProcess>(); prevProcess.IsRunning().Returns(true); engine.SetRunningProcess(prevProcess); engine.StartNewActivateProcess(); prevProcess.Received(1).Stop(); process.Received(1).Run(); Assert.That(engine.GetCurRunningProcess_Test(), Is.SameAs(process)); }