Inheritance: ConfigureActivityMessage
        public void WorkflowDesignerViewModel_PerformAddItems_DecisionActivity_EditDecisionMessageWithIsNewTruePublished()
        {
            #region Setup view model constructor parameters

            var repo = new Mock<IResourceRepository>();
            var env = EnviromentRepositoryTest.CreateMockEnvironment();
            env.Setup(e => e.ResourceRepository).Returns(repo.Object);

            var crm = new Mock<IContextualResourceModel>();
            crm.Setup(r => r.Environment).Returns(env.Object);
            crm.Setup(r => r.ResourceName).Returns("Test");
            crm.Setup(res => res.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.xmlServiceDefinition));

            var wh = new Mock<IWorkflowHelper>();

            #endregion

            var environmentRepository = SetupEnvironmentRepo(Guid.Empty); // Set the active environment
            #region setup Mock ModelItem

            var properties = new Dictionary<string, Mock<ModelProperty>>();
            var propertyCollection = new Mock<ModelPropertyCollection>();
            var testAct = DsfActivityFactory.CreateDsfActivity(crm.Object, new DsfActivity(), true, environmentRepository, true);

            var prop = new Mock<ModelProperty>();
            prop.Setup(p => p.ComputedValue).Returns(testAct);
            properties.Add("Action", prop);

            propertyCollection.Protected().Setup<ModelProperty>("Find", "Action", true).Returns(prop.Object);

            var source = new Mock<ModelItem>();
            source.Setup(s => s.Properties).Returns(propertyCollection.Object);
            source.Setup(s => s.ItemType).Returns(typeof(FlowDecision));

            #endregion

            #region setup mock to change properties

            //mock item adding - this is obsolote functionality but not refactored due to overhead
            var args = new Mock<ModelChangedEventArgs>();
            #pragma warning disable 618
            args.Setup(a => a.ItemsAdded).Returns(new List<ModelItem> { source.Object });
            #pragma warning restore 618

            #endregion

            #region setup mock ModelChangedEventArgs

            var eventArgs = new Mock<ModelChangedEventArgs>();
            #pragma warning disable 618
            eventArgs.Setup(c => c.ItemsAdded).Returns(new List<ModelItem> { source.Object });
            #pragma warning restore 618

            #endregion

            var eventAggregator = new Mock<IEventAggregator>();
            var wd = new WorkflowDesignerViewModelMock(crm.Object, wh.Object, eventAggregator.Object);
            var expectedMessage = new ConfigureDecisionExpressionMessage
            {
                ModelItem = source.Object,
                EnvironmentModel = crm.Object.Environment,
                IsNew = true
            };

            eventAggregator.Setup(c => c.Publish(It.IsAny<ConfigureDecisionExpressionMessage>()))
                            .Callback<Object>(actualMessage => Assert.AreEqual(expectedMessage.IsNew, ((ConfigureDecisionExpressionMessage)actualMessage).IsNew, "Wrong message published"))
                             .Verifiable();

            // Execute unit
            wd.TestModelServiceModelChanged(eventArgs.Object);

            wd.Dispose();

            eventAggregator.Verify(c => c.Publish(It.IsAny<ConfigureDecisionExpressionMessage>()), Times.Once(), "Dropping a decision onto an auto connect node did not publish configure decision message");
        }
        public void WorkflowDesignerViewModel_ViewPreviewMouseDown_Decision_ConfigureDecisionPublishedWithIsNewFalse()
        {
            #region Setup view model constructor parameters

            var repo = new Mock<IResourceRepository>();
            repo.Setup(r => r.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(new ExecuteMessage());
            var env = EnviromentRepositoryTest.CreateMockEnvironment();
            env.Setup(e => e.ResourceRepository).Returns(repo.Object);

            var crm = new Mock<IContextualResourceModel>();
            crm.Setup(r => r.Environment).Returns(env.Object);
            crm.Setup(r => r.ResourceName).Returns("Test");
            crm.Setup(res => res.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.xmlServiceDefinition));

            var wh = new Mock<IWorkflowHelper>();

            #endregion

            #region setup Mock ModelItem

            var properties = new Dictionary<string, Mock<ModelProperty>>();
            var propertyCollection = new Mock<ModelPropertyCollection>();
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty); // Set the active environment
            var testAct = DsfActivityFactory.CreateDsfActivity(crm.Object, new DsfActivity(), true, environmentRepository, true);

            var prop = new Mock<ModelProperty>();
            prop.Setup(p => p.ComputedValue).Returns(testAct);
            properties.Add("Action", prop);

            propertyCollection.Protected().Setup<ModelProperty>("Find", "Action", true).Returns(prop.Object);

            var source = new Mock<ModelItem>();
            source.Setup(s => s.Properties).Returns(propertyCollection.Object);
            source.Setup(s => s.ItemType).Returns(typeof(FlowDecision));

            #endregion

            #region setup event aggregator

            var eventAggregator = new Mock<IEventAggregator>();

            #endregion

            var wd = new Mock<WorkflowDesignerViewModelMock>(crm.Object, wh.Object, eventAggregator.Object, false);

            wd.Setup(c => c.SelectedModelItem).Returns(source.Object);

            var expectedMessage = new ConfigureDecisionExpressionMessage
            {
                ModelItem = source.Object,
                EnvironmentModel = crm.Object.Environment,
                IsNew = false
            };

            eventAggregator.Setup(c => c.Publish(It.IsAny<ConfigureDecisionExpressionMessage>()))
                            .Callback<Object>(actualMessage => Assert.AreEqual(expectedMessage.IsNew, ((ConfigureDecisionExpressionMessage)actualMessage).IsNew, "Wrong message published"))
                             .Verifiable();

            wd.Object.TestHandleMouseClick(new Mock<DependencyObject>().Object, null);

            wd.Object.Dispose();

            eventAggregator.Verify(c => c.Publish(It.IsAny<ConfigureDecisionExpressionMessage>()), Times.Once(), "Dropping a decision onto an auto connect node did not publish configure decision message");
        }
        // ReSharper disable InconsistentNaming
        public void FlowController_HandleConfigureDecisionExpressionMessageAndIsNewTrue_WizardNotShown()
        // ReSharper restore InconsistentNaming
        {
            #region setup first Mock ModelItem

            var env = EnviromentRepositoryTest.CreateMockEnvironment();

            var properties = new Dictionary<string, Mock<ModelProperty>>();
            var propertyCollection = new Mock<ModelPropertyCollection>();
            var testAct = new DsfFlowDecisionActivity { ExpressionText = "Not Null Test Value" };

            var prop = new Mock<ModelProperty>();
            prop.Setup(p => p.ComputedValue).Returns(testAct);
            properties.Add("Condition", prop);

            propertyCollection.Protected().Setup<ModelProperty>("Find", "Condition", true).Returns(prop.Object);

            var source = new Mock<ModelItem>();
            source.Setup(s => s.Properties).Returns(propertyCollection.Object);

            #endregion

            #region setup decision Mock ModelItem

            var crmDecision = new Mock<IContextualResourceModel>();
            crmDecision.Setup(r => r.Environment).Returns(env.Object);
            crmDecision.Setup(r => r.ResourceName).Returns("Test");
            crmDecision.Setup(res => res.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.xmlServiceDefinition));

            var decisionProperties = new Dictionary<string, Mock<ModelProperty>>();
            var decisionPropertyCollection = new Mock<ModelPropertyCollection>();

            var decisionProp = new Mock<ModelProperty>();
            decisionProp.Setup(p => p.ComputedValue).Returns(string.Empty);
            decisionProperties.Add("Condition", decisionProp);

            decisionPropertyCollection.Protected().Setup<ModelProperty>("Find", "Condition", true).Returns(decisionProp.Object);

            var decisionModelItem = new Mock<ModelItem>();
            decisionModelItem.Setup(s => s.Properties).Returns(decisionPropertyCollection.Object);
            decisionModelItem.Setup(s => s.ItemType).Returns(typeof(FlowDecision));

            prop.Setup(p => p.Value).Returns(decisionModelItem.Object);

            #endregion

            #region setup Environment Model

            env.Setup(c => c.Connection).Returns(new Mock<IEnvironmentConnection>().Object);

            #endregion

            var flowController = new FlowController(new Mock<IPopupController>().Object);
            var message = new ConfigureDecisionExpressionMessage { ModelItem = source.Object, EnvironmentModel = env.Object, IsNew = true };

            flowController.Handle(message);
        }