public void ExecuteMethodChangesElementStatusBeforeExecutingTheFxGroup()
        {
            ISetParamMgr setterParamMgr = _element as ISetParamMgr;
            ISetPortMgrs setterPortsMgr = _element as ISetPortMgrs;
            ISetSimpleFx setterFx = _element as ISetSimpleFx;

            ValidationResults results1 = null;
            ValidationResults results2 = null;
            var mockParamMgr = new Mock<IIdentNodeCoresParamMgr>();
            var mockInPortMgr = new Mock<IInputPortMgr>();
            var mockOutPortMgr = new Mock<IOutputPortMgr>();
            var mockFx = new Mock<IIdentNodeCoresFx>();

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.DefaultBehavior.Strict = StrictFlags.ArbitraryMethodsAllowed;
                recorder.ExpectAndReturn(_element.OutPortMgr, mockOutPortMgr).RepeatAlways();
                recorder.ExpectAndReturn(mockOutPortMgr.PortStatuses, null).RepeatAlways();
                recorder.ExpectAndReturn(mockInPortMgr.Validate(out results1), true);
                recorder.ExpectAndReturn(mockParamMgr.Validate(out results2), true);
                mockFx.Execute(null, null, null, null);
                (_element as SimpleElementBase).Log(LogReasons.Start, null, null);
            }

            ElementStatus initialStatus = _element.Status;

            setterPortsMgr.SetInputMgr(mockInPortMgr);
            setterParamMgr.SetMgr(mockParamMgr);
            setterFx.SetFxGroup(mockFx);
            _element.Execute();
            ElementStatus expectedStatus = _element.Status;
            MockManager.Verify();

            Assert.Equal(ElementStatus.Incomplete, initialStatus);
            Assert.Equal(ElementStatus.Executing, expectedStatus);
        }
            public void Execute_Func_throws_on_null_parameters()
            {
                var mockExecutionStrategy =
                    new Mock<DbExecutionStrategy>
                        {
                            CallBase = true
                        }.Object;

                Assert.Equal(
                    "operation",
                    Assert.Throws<ArgumentNullException>(() => mockExecutionStrategy.Execute((Func<int>)null)).ParamName);
            }
        public void Execute_WhenStatusIsComplete()
        {
            var mockEl = new Mock<DummyCompoundElement>();

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.ExpectAndReturn(mockEl.Status, ElementStatus.Complete).Repeat(2);
                mockEl.ResetWithNotification(false);
                mockEl.ExecutionProper();
            }

            mockEl.Execute();
            MockManager.Verify();
        }
            public void Execute_Action_throws_on_null_parameters()
            {
                var mockExecutionStrategy =
                    new Mock<ExecutionStrategyBase>
                        {
                            CallBase = true
                        }.Object;

                Assert.Equal(
                    "action",
                    Assert.Throws<ArgumentNullException>(() => mockExecutionStrategy.Execute(null)).ParamName);
            }
        public void Execute_WhenStatusIsValidating()
        {
            var mockEl = new Mock<DummyCompoundElement>();

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.ExpectAndReturn(mockEl.Status, ElementStatus.Validating).Repeat(4);
                mockEl.Cancel();
                mockEl.ExecutionProper();
            }

            mockEl.Execute();
            MockManager.Verify();
        }