コード例 #1
0
        public void ResourcePickerDialog_Constructor_EnvironmentModelIsNotNull_EnvironmentRepositoryIsNew()
        {
            //------------Setup for test-------------------------
            SetupMef();
            var dialogWindow = new Mock <IDialog>();

            //------------Execute Test---------------------------
            var environmentModel = new Mock <IEnvironmentModel>().Object;
            var dialog           = new TestResourcePickerDialog(enDsfActivityType.All, environmentModel)
            {
                CreateDialogResult = dialogWindow.Object
            };

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

            //------------Assert Results-------------------------
            Assert.AreNotSame(EnvironmentRepository.Instance, dialog.CreateDialogDataContext.NavigationViewModel.EnvironmentRepository);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        public void ResourcePickerDialog_Constructor_EnvironmentModelIsNotNull_EnvironmentRepositoryIsNew()
        {
            //------------Setup for test-------------------------
            SetupMef();
            var dialogWindow = new Mock<IDialog>();

            //------------Execute Test---------------------------
            var environmentModel = new Mock<IEnvironmentModel>().Object;
            var dialog = new TestResourcePickerDialog(enDsfActivityType.All, environmentModel) { CreateDialogResult = dialogWindow.Object };
            // Need to invoke ShowDialog in order to get the DsfActivityDropViewModel
            dialog.ShowDialog();

            //------------Assert Results-------------------------
            Assert.AreNotSame(EnvironmentRepository.Instance, dialog.CreateDialogDataContext.NavigationViewModel.EnvironmentRepository);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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);
        }