/// <summary>
 /// Creates a picker suitable for dropping from the toolbox.
 /// </summary>
 public TestResourcePickerDialog(enDsfActivityType activityType)
     : base(activityType)
 {
     var dialog = new Mock<IDialog>();
     dialog.Setup(d => d.ShowDialog()).Verifiable();
     CreateDialogResult = dialog.Object;
 }
        /// <summary>
        /// Creates a picker suitable for dropping from the toolbox.
        /// </summary>
        public TestResourcePickerDialog(enDsfActivityType activityType)
            : base(activityType)
        {
            var dialog = new Mock <IDialog>();

            dialog.Setup(d => d.ShowDialog()).Verifiable();
            CreateDialogResult = dialog.Object;
        }
 public DsfActivityDropViewModel(INavigationViewModel navigationViewModel, enDsfActivityType dsfActivityType)
 {
     NavigationViewModel = navigationViewModel;
     ActivityType        = dsfActivityType;
     NavigationViewModel.PropertyChanged += CheckIfSelectedItemChanged;
     Init();
     EventPublishers.Aggregator.Subscribe(this);
 }
 public DsfActivityDropViewModel(INavigationViewModel navigationViewModel, enDsfActivityType dsfActivityType)
 {
     NavigationViewModel = navigationViewModel;
     ActivityType = dsfActivityType;
     NavigationViewModel.PropertyChanged+=CheckIfSelectedItemChanged;
     Init();
     EventPublishers.Aggregator.Subscribe(this);
 }
Ejemplo n.º 5
0
        public DsfActivityDropViewModel(INavigationViewModel navigationViewModel, enDsfActivityType dsfActivityType)
        {
            NavigationViewModel = navigationViewModel;
            ActivityType        = dsfActivityType;

            Init();
            EventPublishers.Aggregator.Subscribe(this);
        }
Ejemplo n.º 6
0
        public DsfActivityDropViewModel(IExplorerViewModel explorerViewModel, enDsfActivityType dsfActivityType)
        {
            SingleEnvironmentExplorerViewModel = explorerViewModel;
            SingleEnvironmentExplorerViewModel.SelectedItemChanged += SingleEnvironmentExplorerViewModel_SelectedItemChanged;
            ActivityType = dsfActivityType;

            Init();
            EventPublishers.Aggregator.Subscribe(this);
        }
 public ResourcePickerDialog(enDsfActivityType activityType, IEnvironmentRepository environmentRepository, IEventAggregator eventPublisher, IAsyncWorker asyncWorker, bool isFromDrop, IStudioResourceRepository studioResourceRepository, IConnectControlSingleton connectControlSingleton)
 {
     VerifyArgument.IsNotNull("environmentRepository", environmentRepository);
     VerifyArgument.IsNotNull("eventPublisher", eventPublisher);
     VerifyArgument.IsNotNull("asyncWorker", asyncWorker);
     VerifyArgument.IsNotNull("connectControlSingleton", connectControlSingleton);
     _studio = studioResourceRepository;
     _navigationViewModel = new NavigationViewModel(eventPublisher, asyncWorker, null, environmentRepository, studioResourceRepository,connectControlSingleton, () => {}, isFromDrop, activityType);
     _activityType = activityType;
 }
Ejemplo n.º 8
0
        public ResourcePickerDialog(enDsfActivityType activityType, IEnvironmentViewModel environmentViewModel, IEventAggregator eventPublisher, IAsyncWorker asyncWorker, IConnectControlSingleton connectControlSingleton)
        {
            VerifyArgument.IsNotNull("environmentRepository", environmentViewModel);
            VerifyArgument.IsNotNull("eventPublisher", eventPublisher);
            VerifyArgument.IsNotNull("asyncWorker", asyncWorker);
            VerifyArgument.IsNotNull("connectControlSingleton", connectControlSingleton);

            SingleEnvironmentExplorerViewModel = new SingleEnvironmentExplorerViewModel(environmentViewModel, Guid.Empty, true);
            SingleEnvironmentExplorerViewModel.SelectedItemChanged += (sender, item) => { SelectedResource = item; };
            _activityType = activityType;
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        public void ResourcePickerDialog_SelectedResourceNotNull_NavigationViewModelActivityDropViewModelItemSelected()
        {
            //------------Setup for test-------------------------
            SetupMef();
            var dialogWindow = new Mock <IDialog>();
            const enDsfActivityType ActivityType = enDsfActivityType.All;
            const bool IsFromActivityDrop        = true;
            var        repository = new StudioResourceRepository(GetTestData(), Guid.Empty, _Invoke);

            var mockEnvironmentModel = new Mock <IEnvironmentModel>();
            var mockEventAggregator  = new Mock <IEventAggregator>();

            mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true);
            mockEnvironmentModel.Setup(model => model.CanStudioExecute).Returns(true);
            mockEnvironmentModel.Setup(model => model.Equals(It.IsAny <IEnvironmentModel>())).Returns(true);

            var mockEnvironmentConnection = new Mock <IEnvironmentConnection>();

            mockEnvironmentConnection.Setup(connection => connection.AppServerUri).Returns(new Uri("http://localhost"));
            mockEnvironmentConnection.Setup(connection => connection.ServerEvents).Returns(new Mock <IEventPublisher>().Object);
            mockEnvironmentModel.Setup(model => model.Connection).Returns(mockEnvironmentConnection.Object);
            var mockResourceRepository = CreateMockResourceRepository(mockEnvironmentModel);

            mockEnvironmentModel.Setup(model => model.ResourceRepository).Returns(mockResourceRepository.Object);
            var envRepo          = new TestLoadEnvironmentRespository(mockEnvironmentModel.Object);
            var selectedResource = mockResourceRepository.Object.All().ToList()[1];
            var dialog           = new TestResourcePickerDialog(ActivityType, envRepo, mockEventAggregator.Object, new TestAsyncWorker(), IsFromActivityDrop, repository)
            {
                CreateDialogResult = dialogWindow.Object,
                SelectedResource   = selectedResource
            };

            //------------Execute Test---------------------------

            // Need to invoke ShowDialog in order to get the DsfActivityDropViewModel
            dialog.ShowDialog();

            //------------Assert Results-------------------------
            Assert.AreEqual(selectedResource, dialog.CreateDialogDataContext.SelectedResourceModel);
        }
Ejemplo n.º 11
0
        public NavigationViewModel(IEventAggregator eventPublisher, IAsyncWorker asyncWorker, Guid?context, IEnvironmentRepository environmentRepository, IStudioResourceRepository studioResourceRepository, IConnectControlSingleton connectControlSingleton, System.Action updateWorkSpaceItems, bool isFromActivityDrop = false, enDsfActivityType activityType = enDsfActivityType.All, NavigationViewModelType navigationViewModelType = NavigationViewModelType.Explorer)
            : base(eventPublisher, asyncWorker, environmentRepository, studioResourceRepository, updateWorkSpaceItems)
        {
            VerifyArgument.IsNotNull("eventPublisher", eventPublisher);
            VerifyArgument.IsNotNull("asyncWorker", asyncWorker);
            VerifyArgument.IsNotNull("environmentRepository", environmentRepository);
            VerifyArgument.IsNotNull("connectControlSingleton", connectControlSingleton);

            _eventPublisher          = eventPublisher;
            _connectControlSingleton = connectControlSingleton;
            _eventPublisher.Subscribe(this);
            EnvironmentRepository = environmentRepository;
            Context = context;

            DsfActivityType               = activityType;
            _fromActivityDrop             = isFromActivityDrop;
            _navigationViewModelType      = navigationViewModelType;
            Environments                  = new List <IEnvironmentModel>();
            ExplorerItemModels            = new ObservableCollection <IExplorerItemModel>();
            CircularProgressBarVisibility = Visibility.Hidden;
            RefreshButtonVisibility       = Visibility.Visible;
        }
Ejemplo n.º 12
0
        public void ResourcePickerDialog_Constructor_Properties_Initialized()
        {
            //------------Setup for test-------------------------
            SetupMef();
            var dialogWindow = new Mock <IDialog>();
            const enDsfActivityType ActivityType = enDsfActivityType.All;
            const bool IsFromActivityDrop        = true;
            var        repository = new StudioResourceRepository(GetTestData(), Guid.Empty, _Invoke);
            var        envRepo    = new TestLoadEnvironmentRespository(new Mock <IEnvironmentModel>().Object);
            //var envRepo = EnvironmentRepository.Create(new Mock<IEnvironmentModel>().Object);

            //------------Execute Test---------------------------
            var dialog = new TestResourcePickerDialog(ActivityType, envRepo, new Mock <IEventAggregator>().Object, new TestAsyncWorker(), IsFromActivityDrop, repository)
            {
                CreateDialogResult = dialogWindow.Object
            };

            // Need to invoke ShowDialog in order to get the DsfActivityDropViewModel
            dialog.ShowDialog();

            //------------Assert Results-------------------------
            Assert.AreEqual(ActivityType, dialog.CreateDialogDataContext.ActivityType);
            Assert.AreEqual(IsFromActivityDrop, dialog.CreateDialogDataContext.NavigationViewModel.IsFromActivityDrop);
        }
 public TestDsfActivityDropViewModel(IExplorerViewModel explorerViewModel, enDsfActivityType dsfActivityType)
     : base(explorerViewModel, dsfActivityType)
 {
 }
Ejemplo n.º 14
0
        public static Task <IResourcePickerDialog> CreateAsync(enDsfActivityType activityType, IEnvironmentViewModel source)
        {
            var ret = new ResourcePickerDialog(activityType, source, EventPublishers.Aggregator, new AsyncWorker(), ConnectControlSingleton.Instance);

            return(ret.InitializeAsync(source));
        }
 /// <summary>
 /// Creates a picker suitable for picking from the given environment.
 /// </summary>
 public TestResourcePickerDialog(enDsfActivityType activityType, IEnvironmentModel source)
     : base(activityType, source)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates a picker suitable for picking from the given environment.
 /// </summary>
 public ResourcePickerDialog(enDsfActivityType activityType, IEnvironmentViewModel source)
     : this(activityType, source, EventPublishers.Aggregator, new AsyncWorker(), ConnectControlSingleton.Instance)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Creates a picker suitable for dropping from the toolbox.
 /// </summary>
 /// //todo:fix ctor for testing
 public ResourcePickerDialog(enDsfActivityType activityType)
     : this(activityType, null, EventPublishers.Aggregator, new AsyncWorker(), ConnectControlSingleton.Instance)
 {
 }
Ejemplo n.º 18
0
 public DsfActivityDropViewModel(IExplorerViewModel explorerViewModel, enDsfActivityType dsfActivityType)
     : this(explorerViewModel, dsfActivityType, ServerRepository.Instance)
 {
 }
 public TestResourcePickerDialog(enDsfActivityType activityType, IEnvironmentRepository environmentRepository, IEventAggregator eventPublisher, IAsyncWorker asyncWorker, bool isFromDrop, IStudioResourceRepository studioResourceRepository)
     : base(activityType, environmentRepository, eventPublisher, asyncWorker, isFromDrop, studioResourceRepository, new Mock<IConnectControlSingleton>().Object)
 {
 }
 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);
 }
 public TestDsfActivityDropViewModel(IExplorerViewModel explorerViewModel, enDsfActivityType dsfActivityType, object sender, IExplorerTreeItem @object) : this(explorerViewModel, dsfActivityType)
 {
     this.sender  = sender;
     this.@object = @object;
 }
Ejemplo n.º 22
0
        public ExplorerViewModel(IEventAggregator eventPublisher, IAsyncWorker asyncWorker, IEnvironmentRepository environmentRepository, IStudioResourceRepository studioResourceRepository, IConnectControlSingleton connectControlSingleton, IMainViewModel mainViewModel, bool isFromActivityDrop = false, enDsfActivityType activityType = enDsfActivityType.All, System.Action updateWorkSpaceItems = null, IConnectControlViewModel connectControlViewModel = null)
            : base(eventPublisher)
        {
            VerifyArgument.IsNotNull("asyncWorker", asyncWorker);
            VerifyArgument.IsNotNull("environmentRepository", environmentRepository);
            VerifyArgument.IsNotNull("connectControlSingleton", connectControlSingleton);

            EnvironmentRepository = environmentRepository;

            NavigationViewModel = new NavigationViewModel(eventPublisher, asyncWorker, Context, environmentRepository, studioResourceRepository, connectControlSingleton, updateWorkSpaceItems, isFromActivityDrop, activityType)
            {
                Parent = this
            };

            ConnectControlViewModel = connectControlViewModel ?? new ConnectControlViewModel(mainViewModel, AddEnvironment, "Connect:", true);
        }
 /// <summary>
 /// Creates a picker suitable for picking from the given environment.
 /// </summary>
 public TestResourcePickerDialog(enDsfActivityType activityType, IEnvironmentModel source)
     : base(activityType, source)
 {
 }
 public TestResourcePickerDialog(enDsfActivityType activityType, IEnvironmentRepository environmentRepository, IEventAggregator eventPublisher, IAsyncWorker asyncWorker, bool isFromDrop, IStudioResourceRepository studioResourceRepository)
     : base(activityType, environmentRepository, eventPublisher, asyncWorker, isFromDrop, studioResourceRepository, new Mock <IConnectControlSingleton>().Object)
 {
 }
Ejemplo n.º 25
0
        public void ResourcePickerDialog_WithEnvironmentModel_NavigationViewModelFiltered()
        {
            //------------Setup for test-------------------------
            SetupMef();
            var dialogWindow = new Mock <IDialog>();
            const enDsfActivityType ActivityType = enDsfActivityType.All;
            const bool IsFromActivityDrop        = true;

            var mockEventAggregator  = new Mock <IEventAggregator>();
            var mockEnvironmentModel = new Mock <IEnvironmentModel>();

            mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true);
            mockEnvironmentModel.Setup(model => model.CanStudioExecute).Returns(true);
            mockEnvironmentModel.Setup(model => model.ID).Returns(Guid.Empty);
            var environment2Id = Guid.NewGuid();

            var mockEnvironmentModel2 = new Mock <IEnvironmentModel>();

            mockEnvironmentModel2.Setup(model => model.IsConnected).Returns(true);
            mockEnvironmentModel2.Setup(model => model.CanStudioExecute).Returns(true);
            mockEnvironmentModel2.Setup(model => model.ID).Returns(environment2Id);

            var mockEnvironmentConnection = new Mock <IEnvironmentConnection>();

            mockEnvironmentConnection.Setup(connection => connection.AppServerUri).Returns(new Uri("http://localhost"));
            mockEnvironmentConnection.Setup(connection => connection.ServerEvents).Returns(new Mock <IEventPublisher>().Object);
            mockEnvironmentModel.Setup(model => model.Connection).Returns(mockEnvironmentConnection.Object);

            var mockEnvironmentConnection2 = new Mock <IEnvironmentConnection>();

            mockEnvironmentConnection2.Setup(connection => connection.AppServerUri).Returns(new Uri("http://tests:3142"));
            mockEnvironmentConnection2.Setup(connection => connection.ServerEvents).Returns(new Mock <IEventPublisher>().Object);
            mockEnvironmentModel2.Setup(model => model.Connection).Returns(mockEnvironmentConnection2.Object);


            var mockResourceRepository = CreateMockResourceRepository(mockEnvironmentModel);

            mockEnvironmentModel.Setup(model => model.ResourceRepository).Returns(mockResourceRepository.Object);
            var envRepo          = new TestLoadEnvironmentRespository(mockEnvironmentModel.Object, mockEnvironmentModel2.Object);
            var selectedResource = mockResourceRepository.Object.All().ToList()[1];

            var mockExplorerResourceRepository = new Mock <IClientExplorerResourceRepository>();

            var repository = new StudioResourceRepository(GetTestData(), Guid.Empty, _Invoke)
            {
                GetExplorerProxy = id => mockExplorerResourceRepository.Object
            };

            ExplorerItemModel server2Item = new ExplorerItemModel {
                EnvironmentId = environment2Id, DisplayName = "Server 2", ResourceType = ResourceType.Server
            };

            ExplorerItemModel resourceItemServer2 = new ExplorerItemModel {
                EnvironmentId = environment2Id, DisplayName = "Resource Server 2", ResourceType = ResourceType.WorkflowService
            };

            server2Item.Children.Add(resourceItemServer2);
            repository.ExplorerItemModels.Add(server2Item);

            var dialog = new TestResourcePickerDialog(ActivityType, envRepo, mockEventAggregator.Object, new TestAsyncWorker(), IsFromActivityDrop, repository)
            {
                CreateDialogResult = dialogWindow.Object,
                SelectedResource   = new Mock <IResourceModel>().Object
            };

            //------------Execute Test---------------------------

            // Need to invoke ShowDialog in order to get the DsfActivityDropViewModel
            dialog.ShowDialog(mockEnvironmentModel2.Object);

            //------------Assert Results-------------------------
            Assert.AreNotEqual(selectedResource, dialog.CreateDialogDataContext.SelectedResourceModel);
        }
 /// <summary>
 /// Creates a picker suitable for picking from the given environment.
 /// </summary>
 public ResourcePickerDialog(enDsfActivityType activityType, IEnvironmentModel source)
     : this(activityType, EnvironmentRepository.Create(source), EventPublishers.Aggregator, new AsyncWorker(), false, StudioResourceRepository.Instance, ConnectControlSingleton.Instance)
 {
 }
 public TestDsfActivityDropViewModel(IExplorerViewModel explorerViewModel, enDsfActivityType dsfActivityType, object sender, IExplorerTreeItem e, IServerRepository @object)
     : base(explorerViewModel, dsfActivityType)
 {
 }
        //NavigationViewModel CreateViewModel(Mock<IResourceRepository> mockResourceRepository, bool isFromActivityDrop = false, enDsfActivityType activityType = enDsfActivityType.All, Mock<IConnectControlSingleton> connectControlASingleton = null)
        //{
        //    var importServiceContext = new ImportServiceContext();
        //    ImportService.CurrentContext = importServiceContext;

        //    ImportService.Initialize(new List<ComposablePartCatalog>());

        //    return CreateViewModel(EnvironmentRepository.Instance, mockResourceRepository, isFromActivityDrop, activityType, connectControlASingleton);
        //}

        NavigationViewModel CreateViewModel(IEnvironmentRepository environmentRepository, Mock<IResourceRepository> mockResourceRepository, bool isFromActivityDrop = false, enDsfActivityType activityType = enDsfActivityType.All, Mock<IConnectControlSingleton> connectControlASingleton = null, bool mockClone = true)
        {
            var studioResourceRepository = BuildExplorerItems(mockResourceRepository.Object,mockClone);
            connectControlASingleton = connectControlASingleton ?? new Mock<IConnectControlSingleton>();
            var navigationViewModel = new NavigationViewModel(new Mock<IEventAggregator>().Object, new TestAsyncWorker(), null, environmentRepository, studioResourceRepository, connectControlASingleton.Object, () => { }, isFromActivityDrop, activityType);
            return navigationViewModel;
        }