Inheritance: ConfigureActivityMessage
        public void WorkflowDesignerViewModel_ViewPreviewMouseDown_Switch_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

            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(FlowSwitch<string>));

            #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 ConfigureSwitchExpressionMessage
            {
                ModelItem = source.Object,
                EnvironmentModel = crm.Object.Environment,
                IsNew = false
            };

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

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

            wd.Object.Dispose();

            eventAggregator.Verify(c => c.Publish(It.IsAny<ConfigureSwitchExpressionMessage>()), Times.Once(), "Dropping a switch onto an auto connect node did not publish configure switch message");
        }
        public void WorkflowDesignerViewModel_PerformAddItems_SwitchActivity_SwitchMessageWithIsNewTruePublished()
        {
            #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

            #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(FlowSwitch<string>));

            #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

            #region setup event aggregator

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

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

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

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

            wd.Dispose();

            eventAggregator.Verify(c => c.Publish(It.IsAny<ConfigureSwitchExpressionMessage>()), Times.Once(), "Dropping a switch onto an auto connect node did not publish configure switch message");
        }