SetDataObject() 공개 메소드

public SetDataObject ( dynamic dataobject ) : void
dataobject dynamic
리턴 void
예제 #1
0
        public void WorkflowDesignerViewModel_PerformAddItems_ForEachActivity_DragOnRemoteWorkflow()
        {
            #region Setup view model constructor parameters

            if (Application.Current != null)
            {
                try
                {
                    Application.Current.MainWindow = null;
                }
                catch (InvalidOperationException)
                {

                }
            }
            var repo = new Mock<IResourceRepository>();
            var mockResourceModel = new Mock<IContextualResourceModel>();
            mockResourceModel.Setup(model => model.ID).Returns(Guid.NewGuid());
            var mockRemoteEnvironment = new Mock<IEnvironmentModel>();
            var remoteServerID = Guid.NewGuid();
            mockRemoteEnvironment.Setup(model => model.ID).Returns(remoteServerID);
            var mockRemoteConnection = new Mock<IEnvironmentConnection>();
            mockRemoteConnection.Setup(connection => connection.WebServerUri).Returns(new Uri("http://remoteserver:3142/"));
            mockRemoteEnvironment.Setup(model => model.Connection).Returns(mockRemoteConnection.Object);
            mockResourceModel.Setup(model => model.Environment).Returns(mockRemoteEnvironment.Object);
            repo.Setup(repository => repository.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), It.IsAny<bool>(), It.IsAny<bool>())).Returns(mockResourceModel.Object);
            var env = EnviromentRepositoryTest.CreateMockEnvironment();
            env.Setup(model => model.ID).Returns(Guid.Empty);
            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

            GetEnvironmentRepository(env); // Set the active environment

            #region setup mock ModelChangedEventArgs

            var eventArgs = new Mock<ModelChangedEventArgs>();
            #pragma warning disable 618
            eventArgs.Setup(c => c.ItemsAdded).Returns((IEnumerable<ModelItem>)null);
            var mock = new Mock<ModelProperty>();
            DsfActivity setValue = null;
            mock.Setup(property => property.SetValue(It.IsAny<object>())).Callback<object>(o =>
            {
                setValue = o as DsfActivity;
            });
            mock.Setup(property => property.Name).Returns("Handler");
            eventArgs.Setup(c => c.PropertiesChanged).Returns(new List<ModelProperty> { mock.Object });
            #pragma warning restore 618

            #endregion

            var eventAggregator = new Mock<IEventAggregator>();
            var wd = new WorkflowDesignerViewModelMock(crm.Object, wh.Object, eventAggregator.Object);
            wd.SetActiveEnvironment(env.Object);
            wd.SetDataObject(new ExplorerItemModel(new Mock<IStudioResourceRepository>().Object, new TestAsyncWorker(), new Mock<IConnectControlSingleton>().Object));

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

            wd.Dispose();
            Assert.IsNotNull(setValue);
            Assert.AreEqual("http://remoteserver:3142/", setValue.ServiceUri);
            Assert.AreEqual(remoteServerID, setValue.ServiceServer);
        }
예제 #2
0
        public void WorkflowDesignerViewModelTestStartNodeNotDoubleConnect()
        {
            #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));
            //, new Mock<IWizardEngine>().Object
            var explorerItem = new ExplorerItemModel();
            IContextualResourceModel contextualResourceModel = crm.Object;
            explorerItem.DisplayName = contextualResourceModel.ResourceName;
            explorerItem.EnvironmentId = contextualResourceModel.Environment.ID;

            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(contextualResourceModel, new DsfActivity(), true, environmentRepository, true);

            var prop = new Mock<ModelProperty>();
            prop.Setup(p => p.SetValue(It.IsAny<DsfActivity>())).Verifiable();
            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(FlowStep));

            #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

            //Execute
            var wfd = new WorkflowDesignerViewModelMock(contextualResourceModel, wh.Object);
            wfd.SetDataObject(explorerItem);
            wfd.TestModelServiceModelChanged(args.Object);

            wfd.Dispose();

            //Verify
            prop.Verify(p => p.SetValue(It.IsAny<DsfActivity>()), Times.Never());
        }