当前位置: 首页>>代码示例>>C#>>正文


C# MainViewModel.AddDeployResourcesWorkSurface方法代码示例

本文整理汇总了C#中MainViewModel.AddDeployResourcesWorkSurface方法的典型用法代码示例。如果您正苦于以下问题:C# MainViewModel.AddDeployResourcesWorkSurface方法的具体用法?C# MainViewModel.AddDeployResourcesWorkSurface怎么用?C# MainViewModel.AddDeployResourcesWorkSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainViewModel的用法示例。


在下文中一共展示了MainViewModel.AddDeployResourcesWorkSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainViewModel_AddDeployResourceWorksurface_PublishesSelectItemInDeployMessage

        public void MainViewModel_AddDeployResourceWorksurface_PublishesSelectItemInDeployMessage()
        {
            SelectItemInDeployMessage actual = null;
            var eventAggregator = new Mock<IEventAggregator>();
            eventAggregator.Setup(e => e.Publish(It.IsAny<object>())).Callback((object msg) => actual = msg as SelectItemInDeployMessage).Verifiable();
            #region Setup ImportService - GRRR!
            //Barney, commented out when I removed the feedback stuff from the studio
            //SetupDefaultMef();
            #endregion

            var resourceID = Guid.NewGuid();
            var environmentID = Guid.NewGuid();
            var envRepo = new Mock<IEnvironmentRepository>();
            envRepo.Setup(e => e.All()).Returns(new List<IEnvironmentModel>());
            Mock<IResourceRepository> mockResourceRepository = new Mock<IResourceRepository>();
            Mock<IContextualResourceModel> mockResourceModel = new Mock<IContextualResourceModel>();
            mockResourceModel.Setup(model => model.ID).Returns(resourceID);
            mockResourceRepository.Setup(repository => repository.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), false, false)).Returns(mockResourceModel.Object);
            Mock<IEnvironmentModel> mockEnvironmentModel = new Mock<IEnvironmentModel>();
            mockEnvironmentModel.Setup(model => model.ID).Returns(environmentID);
            mockEnvironmentModel.Setup(model => model.ResourceRepository).Returns(mockResourceRepository.Object);
            var environmentModel = mockEnvironmentModel.Object;
            mockResourceModel.Setup(model => model.Environment).Returns(environmentModel);
            envRepo.Setup(e => e.Source).Returns(environmentModel);
            envRepo.Setup(e => e.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(environmentModel);
            envRepo.Setup(e => e.Source.IsConnected).Returns(false);
            envRepo.Setup(e => e.Source.Connection.IsConnected).Returns(false);
            var vm = new MainViewModel(eventAggregator.Object, new TestAsyncWorker(), envRepo.Object, new Mock<IVersionChecker>().Object, false, new Mock<IBrowserPopupController>().Object);
            vm.AddDeployResourcesWorkSurface(mockResourceModel.Object);
            var expected = new Mock<IExplorerItemModel>();
            expected.Setup(model => model.ResourceId).Returns(resourceID);
            expected.Setup(model => model.EnvironmentId).Returns(environmentModel.ID);
            vm.AddDeployResourcesWorkSurface(mockResourceModel.Object);
            eventAggregator.Verify(e => e.Publish(It.IsAny<object>()), "MainViewModel Handle DeployResourcesMessage did not publish message with the selected view model.");
            Assert.IsNotNull(actual, "MainViewModel Handle DeployResourcesMessage did not publish message with the selected view model.");
            Assert.AreEqual(expected.Object.ResourceId, actual.ResourceID, "MainViewModel Handle DeployResourcesMessage did not publish message with the selected display name.");
            Assert.AreEqual(expected.Object.EnvironmentId, actual.EnvironmentID, "MainViewModel Handle DeployResourcesMessage did not publish message with the selected environment.");
        }
开发者ID:ndubul,项目名称:Chillas,代码行数:38,代码来源:MainViewModelTest.cs


注:本文中的MainViewModel.AddDeployResourcesWorkSurface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。