Inheritance: Dev2.Studio.Core.ViewModels.Base.SimpleBaseViewModel
        protected override IDialog CreateDialog(DsfActivityDropViewModel dataContext)
        {
            dataContext.DialogResult = ViewModelDialogResults.Okay;
            dataContext.SelectedResourceModel = new Mock<IContextualResourceModel>().Object;
            CreateDialogDataContext = dataContext;

            var dialog = new Mock<IDialog>();
            return dialog.Object;
        }
 public void DsfActivityDropViewModel_Okay_NavigationViewModelSelectedItemIsValid_SelectedResourceModelIsSet()
 {
     //------------Setup for test--------------------------
     var navigationVM = new Mock<INavigationViewModel>();
     navigationVM.Setup(m => m.SelectedItem).Returns(new ExplorerItemModel
     {
         ResourceType = ResourceType.WorkflowService,
         ResourceId = Guid.NewGuid(),
         EnvironmentId = Guid.NewGuid()
     });
     var vm = new DsfActivityDropViewModel(navigationVM.Object, enDsfActivityType.All);
     var environmentModel = new Mock<IEnvironmentModel>();
     var resourceModel = new Mock<IContextualResourceModel>();
     var resourceRepo = new Mock<IResourceRepository>();
     resourceRepo.Setup(m => m.FindSingleWithPayLoad(It.IsAny<Expression<Func<IResourceModel, bool>>>()))
                 .Returns(resourceModel.Object);
     environmentModel.Setup(m => m.ResourceRepository).Returns(resourceRepo.Object);
     vm.GetEnvironmentRepository = () =>
     {
         var env = new Mock<IEnvironmentRepository>();
         env.Setup(m => m.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>()))
                         .Returns(environmentModel.Object);
         return env.Object;
     };
     //------------Execute Test---------------------------
     vm.Okay();
     //------------Assert Results-------------------------
     Assert.IsNotNull(vm.SelectedResourceModel);
     Assert.IsTrue(vm.CloseRequested);
 }
        public void DsfActivityDropViewModel_Okay_EnvironmentNotFoundOnTheEnvironmentRepository_SelectedResourceModelIsSet()
        {
            //------------Setup for test--------------------------
            var navigationVM = new Mock<INavigationViewModel>();
            navigationVM.Setup(m => m.SelectedItem).Returns(new ExplorerItemModel
            {
                ResourceType = ResourceType.WorkflowService,
                ResourceId = Guid.NewGuid(),
                EnvironmentId = Guid.NewGuid()
            });

            var vm = new DsfActivityDropViewModel(navigationVM.Object, enDsfActivityType.All)
                {
                    GetEnvironmentRepository = () =>
                        {
                            var env = new Mock<IEnvironmentRepository>();
                            env.Setup(m => m.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>()))
                               .Returns((IEnvironmentModel)null);
                            return env.Object;
                        }
                };
            //------------Execute Test---------------------------
            vm.Okay();
            //------------Assert Results-------------------------
            Assert.IsNull(vm.SelectedResourceModel);
            Assert.IsFalse(vm.CloseRequested);
        }
 public void DsfActivityDropViewModel_Okay_NavigationViewModelSelectedItemIsNull_SelectedResourceModelIsNotSet()
 {
     //------------Setup for test--------------------------
     var navigationVM = new Mock<INavigationViewModel>();
     navigationVM.Setup(m => m.SelectedItem).Returns((ExplorerItemModel)null);
     var vm = new DsfActivityDropViewModel(navigationVM.Object, enDsfActivityType.All);
     //------------Execute Test---------------------------
     vm.Okay();
     //------------Assert Results-------------------------
     Assert.IsNull(vm.SelectedResourceModel);
     Assert.IsFalse(vm.CloseRequested);
 }
 public void DsfActivityDropViewModel_CanOk_SelectedItemIsNull_False()
 {
     var navigationVM = new Mock<INavigationViewModel>();
     navigationVM.Setup(m => m.SelectedItem).Returns((ExplorerItemModel)null);
     var vm = new DsfActivityDropViewModel(navigationVM.Object, enDsfActivityType.All);
     Assert.AreEqual(false, vm.CanOkay);
 }
 static void RunCanOkTestCases(ResourceType resourceType, enDsfActivityType ty, bool expected)
 {
     var navigationVM = new Mock<INavigationViewModel>();
     navigationVM.Setup(m => m.SelectedItem).Returns(new ExplorerItemModel
         {
             ResourceType = resourceType
         });
     var vm = new DsfActivityDropViewModel(navigationVM.Object, ty);
     Assert.AreEqual(expected, vm.CanOkay);
 }
 protected override IDialog CreateDialog(DsfActivityDropViewModel dataContext)
 {
     CreateDialogDataContext = dataContext;
     return CreateDialogResult;
 }