Наследование: Dev2.Studio.Core.EnvironmentRepository
 private static void GetEnvironmentRepository(Mock<IEnvironmentModel> mockEnvironment)
 {
     var repo = new TestLoadEnvironmentRespository(mockEnvironment.Object) { IsLoaded = true };
     // ReSharper disable ObjectCreationAsStatement
     new EnvironmentRepository(repo);
     // ReSharper restore ObjectCreationAsStatement
 }
        public void CreateKeysWithDebugStateExpectedKeysCreatedWhenHasWorkspaceID()
        {
            var resId = Guid.NewGuid();
            var serverId = Guid.NewGuid();
            var enviroId = Guid.NewGuid();
            var enviroId2 = Guid.NewGuid();

            var source = new Mock<IEnvironmentModel>();
            var sourceConnection = new Mock<IEnvironmentConnection>();
            sourceConnection.Setup(connection => connection.WorkspaceID).Returns(Guid.NewGuid);
            source.Setup(model => model.Connection).Returns(sourceConnection.Object);
            var e1 = new Mock<IEnvironmentModel>();
            e1.Setup(model => model.ID).Returns(Guid.NewGuid);
            var connection1 = new Mock<IEnvironmentConnection>();
            connection1.Setup(connection => connection.WorkspaceID).Returns(enviroId);
            e1.Setup(model => model.Connection).Returns(connection1.Object);
            var e2 = new Mock<IEnvironmentModel>();
            e2.Setup(model => model.ID).Returns(Guid.NewGuid);
            var connection2 = new Mock<IEnvironmentConnection>();
            connection2.Setup(connection => connection.WorkspaceID).Returns(enviroId2);
            e2.Setup(model => model.Connection).Returns(connection2.Object);
            var repo = new TestLoadEnvironmentRespository(source.Object, e1.Object, e2.Object);
            // ReSharper disable ObjectCreationAsStatement
            new EnvironmentRepository(repo);
            // ReSharper restore ObjectCreationAsStatement
            var debugState = new Mock<IDebugState>();
            debugState.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState.Setup(c => c.ServerID).Returns(serverId);
            debugState.Setup(c => c.WorkspaceID).Returns(enviroId);

            var key1 = WorkSurfaceKeyFactory.CreateKey(debugState.Object);



            var debugState2 = new Mock<IDebugState>();
            debugState2.Setup(c => c.OriginatingResourceID).Returns(resId);
            debugState2.Setup(c => c.ServerID).Returns(serverId);
            debugState2.Setup(c => c.WorkspaceID).Returns(enviroId2);

            var key2 = WorkSurfaceKeyFactory.CreateKey(debugState2.Object);
            Assert.IsFalse(WorkSurfaceKeyEqualityComparer.Current.Equals(key1, key2), "keys should not be equal");
        }
 private static IEnvironmentRepository GetEnvironmentRepository(Mock<IEnvironmentModel> mockEnvironment)
 {
     var repo = new TestLoadEnvironmentRespository(mockEnvironment.Object) { IsLoaded = true };
     return repo;
 }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
0
        public void EnvironmentRepositoryLoadExpectedSetsIsLoadedToFalseAndInvokesLoadInternal()
        {
            var source = new Mock<IEnvironmentModel>();
            var e1 = new Mock<IEnvironmentModel>();
            var e2 = new Mock<IEnvironmentModel>();

            var repo = new TestLoadEnvironmentRespository(source.Object, e1.Object, e2.Object) { IsLoaded = true };
            Assert.IsTrue(repo.IsLoaded);
            repo.ForceLoad();
            Assert.IsFalse(repo.IsLoaded);
            Assert.AreEqual(1, repo.LoadInternalHitCount);
        }