public void SetDataList_Expected_CurrentDataListSetInSingleton()
        {
            Mock <IDataListViewModel> mockdataListViewModel = Dev2MockFactory.SetupDataListViewModel();

            DataListSingleton.SetDataList(mockdataListViewModel.Object);
            Assert.AreEqual(DataListSingleton.ActiveDataList, mockdataListViewModel.Object);
        }
        public void DeploySummaryPredicateExisting_EnvironmentContainsResourceWithSameIDButDifferentName_ExpectedTrue()
        {
            Guid resourceGuid = Guid.NewGuid();
            Mock <IContextualResourceModel> mockResourceModel = CreateMockResourceModel(resourceGuid, "OtherResource");
            IEnvironmentModel environmentModel;

            IExplorerItemModel       resourceVm;
            IExplorerItemModel       rootItem;
            StudioResourceRepository studioResourceRepository = CreateModels(false, mockResourceModel, out environmentModel, out resourceVm, out rootItem);


            Mock <IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService, resourceGuid);


            environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>()).Object;

            var navigationViewModel             = CreateDeployNavigationViewModel(environmentModel, studioResourceRepository);
            ExplorerItemModel explorerItemModel = new ExplorerItemModel {
                DisplayName = "localhost", ResourceType = ResourceType.Server
            };

            explorerItemModel.Children.Add(resourceVm);
            navigationViewModel.ExplorerItemModels.Add(explorerItemModel);
            navigationViewModel.Environment = environmentModel;
            resourceVm.IsChecked            = true;
            bool actual = DeployStatsCalculator.DeploySummaryPredicateExisting(resourceVm, navigationViewModel);

            Assert.IsTrue(actual);
            Assert.IsTrue(DeployStatsCalculator.ConflictingResources.Count > 0);
        }
        public void DataListViewModel_DifferentVariablesCollection_Object_Is_NOT_Equal()
        {
            //---------------Set up test pack-------------------
            var mockResourceModel = Dev2MockFactory.SetupResourceModelMock();

            var dataListViewModel  = new DataListViewModel(new Mock <IEventAggregator>().Object);
            var dataListViewModel1 = new DataListViewModel(new Mock <IEventAggregator>().Object);

            dataListViewModel.InitializeDataListViewModel(mockResourceModel.Object);
            dataListViewModel1.InitializeDataListViewModel(mockResourceModel.Object);
            dataListViewModel.RecsetCollection.Clear();
            dataListViewModel.ScalarCollection.Clear();
            dataListViewModel1.RecsetCollection.Clear();
            dataListViewModel1.ScalarCollection.Clear();
            dataListViewModel1.ComplexObjectCollection.Clear();
            dataListViewModel.ComplexObjectCollection.Clear();

            var carRecordset = DataListItemModelFactory.CreateRecordSetItemModel("Car", "A recordset of information about a car");

            carRecordset.Children.Add(DataListItemModelFactory.CreateRecordSetFieldItemModel("Make", "Make of vehicle", carRecordset));
            carRecordset.Children.Add(DataListItemModelFactory.CreateRecordSetFieldItemModel("Model", "Model of vehicle", carRecordset));
            carRecordset.Input  = true;
            carRecordset.Output = true;
            dataListViewModel.Add(carRecordset);
            dataListViewModel1.Add(carRecordset);
            dataListViewModel.Add(DataListItemModelFactory.CreateScalarItemModel("Country", "name of Country", enDev2ColumnArgumentDirection.Both));
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dataListViewModel);
            Assert.IsNotNull(dataListViewModel1);
            //---------------Execute Test ----------------------
            var equals = dataListViewModel.Equals(dataListViewModel1);

            //---------------Test Result -----------------------
            Assert.IsFalse(equals);
        }
        public void NewDataListViewModel_Object_IsEqual()
        {
            //---------------Set up test pack-------------------
            var mockResourceModel = Dev2MockFactory.SetupResourceModelMock();

            var dataListViewModel  = new DataListViewModel(new Mock <IEventAggregator>().Object);
            var dataListViewModel1 = new DataListViewModel(new Mock <IEventAggregator>().Object);

            dataListViewModel.InitializeDataListViewModel(mockResourceModel.Object);
            dataListViewModel1.InitializeDataListViewModel(mockResourceModel.Object);
            dataListViewModel.RecsetCollection.Clear();
            dataListViewModel.ScalarCollection.Clear();
            dataListViewModel1.RecsetCollection.Clear();
            dataListViewModel1.ScalarCollection.Clear();
            dataListViewModel1.ComplexObjectCollection.Clear();
            dataListViewModel.ComplexObjectCollection.Clear();


            //---------------Assert Precondition----------------
            Assert.IsNotNull(dataListViewModel);
            Assert.IsNotNull(dataListViewModel1);
            //---------------Execute Test ----------------------
            var equals = dataListViewModel.Equals(dataListViewModel1);

            //---------------Test Result -----------------------
            Assert.IsTrue(equals);
        }
        public void DeploySummaryPredicateNew_UnCheckedNavigationItemViewModel_Expected_False()
        {
            IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel().Object;

            bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(null, environmentModel);

            Assert.IsFalse(actual);
        }
Ejemplo n.º 6
0
        public void MyTestInitialize()
        {
            ImportService.CurrentContext = CompositionInitializer.InitializeForMeflessBaseViewModel();

            _mockDataMappingViewModel = Dev2MockFactory.SetupIDataMappingViewModel();
            _mockWebActivity          = Dev2MockFactory.SetupWebActivityMock();
            _mockInputOutputViewModel = Dev2MockFactory.SetupIInputOutputViewModel("UnitTestDataListItem", "TestValue", "", false, "", false, "InputOutputTestDisplayName", "");
        }
Ejemplo n.º 7
0
        public Mock <IDataListItemModel> CreateDataListItemViewModel(string name, IDataListViewModel dLVM)
        {
            Mock <IDataListItemModel> dataListItemViewModel = Dev2MockFactory.SetupDataListItemViewModel();

            dataListItemViewModel.Setup(dLIVM => dLIVM.DisplayName).Returns(name);
            dataListItemViewModel.Setup(dLIVM => dLIVM.Name).Returns(name);
            return(dataListItemViewModel);
        }
        public void DeploySummaryPredicateNew_NullResourceOnNavigationItemViewModel_Expected_False()
        {
            ExplorerItemModel navigationItemViewModel = new ExplorerItemModel();

            IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel().Object;

            bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel);

            Assert.IsFalse(actual);
        }
Ejemplo n.º 9
0
        public void LoadInputAutoMappingInputOutputViewModelNullRecordSet_Expected_InputOutputViewModelValueNotSet()
        {
            _autoMappingInputAction = new AutoMappingInputAction(_mockDataMappingViewModel.Object, _mockWebActivity.Object);
            IInputOutputViewModel     actual;
            Mock <IDataListViewModel> dataListVM = Dev2MockFactory.SetupDataListViewModel();

            dataListVM.Setup(c => c.DataList).Returns(ReturnDefaultDataListViewModel(dataListVM.Object, false));
            actual = _autoMappingInputAction.LoadInputAutoMapping(_mockInputOutputViewModel.Object);
            _mockInputOutputViewModel.VerifySet(dmVM => dmVM.Value = It.IsAny <string>(), Times.Never());
        }
        public void UpdateActiveDataList_Expected_NewActiveDataList()
        {
            Mock <IDataListViewModel> mockdataListViewModel = Dev2MockFactory.SetupDataListViewModel();

            DataListSingleton.SetDataList(mockdataListViewModel.Object);
            Mock <IDataListViewModel> mock_newDataListViewModel = new Mock <IDataListViewModel>();

            mock_newDataListViewModel.Setup(dataList => dataList.Resource).Returns(Dev2MockFactory.SetupResourceModelMock().Object);
            DataListSingleton.SetDataList(mock_newDataListViewModel.Object);
            Assert.AreNotEqual(DataListSingleton.ActiveDataList, mockdataListViewModel);
        }
        public void DeploySummaryPredicateNew_EnvironmentContainsResource_Expected_False()
        {
            Mock <IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService);

            ExplorerItemModel navigationItemViewModel = new ExplorerItemModel();

            IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>()).Object;

            bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel);

            Assert.IsFalse(actual);
        }
        public void DeploySummaryPredicateNew_NullResourcesOnEnvironmentModel_Expected_False()
        {
            Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService);

            ExplorerItemModel navigationItemViewModel = new ExplorerItemModel();

            Mock <IEnvironmentModel> mockEnvironmentModel = Dev2MockFactory.SetupEnvironmentModel();

            mockEnvironmentModel.Setup(e => e.ResourceRepository).Returns <object>(null);

            IEnvironmentModel environmentModel = mockEnvironmentModel.Object;

            bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel);

            Assert.IsFalse(actual);
        }
        public void DeployStatsCalculator_Calculate_HasFolders_Expect_NoFoldersCounted()
        {
            //------------Setup for test--------------------------


            var conn   = new Mock <IConnectControlSingleton>().Object;
            var studio = new Mock <IStudioResourceRepository>().Object;
            ExplorerItemModel navigationItemViewModel = new ExplorerItemModel(conn, studio)
            {
                ResourceType = ResourceType.Folder, IsChecked = true
            };
            IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel().Object;
            bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel);

            Assert.IsFalse(actual);
        }
Ejemplo n.º 14
0
        public void LoadInputAutoMappingInputOutputViewModelScalarValue_Expected_ReturnedItemThatWasPassedInForInputMapping()
        {
            _autoMappingInputAction = new AutoMappingInputAction(_mockDataMappingViewModel.Object, _mockWebActivity.Object);

            IInputOutputViewModel expected = _mockInputOutputViewModel.Object;
            IInputOutputViewModel actual;

            _mockInputOutputViewModel.Setup(c => c.Value).Returns(string.Empty);

            Mock <IDataListViewModel> mockDataListViewModel = Dev2MockFactory.SetupDataListViewModel();

            mockDataListViewModel.Setup(dlVM => dlVM.DataList).Returns(ReturnDefaultDataListViewModel(mockDataListViewModel.Object, false, "InputOutputTestDisplayName"));
            mockDataListViewModel.Setup(dlVM => dlVM.ScalarCollection).Returns(ReturnDefaultDataListViewModel(mockDataListViewModel.Object, false, "InputOutputTestDisplayName"));
            mockDataListViewModel.Setup(dlVM => dlVM.RecsetCollection).Returns(new OptomizedObservableCollection <IDataListItemModel>());

            DataListSingleton.SetDataList(mockDataListViewModel.Object);

            actual = _autoMappingInputAction.LoadInputAutoMapping(_mockInputOutputViewModel.Object);
            _mockInputOutputViewModel.VerifySet(input => input.Value = It.IsAny <string>(), Times.Exactly(1), "Input View Model failed to set to DataList Representation value");
        }
        public void DeploySummaryPredicateExisting_EnvironmentDoesntContainResource_Expected_False()
        {
            Mock <IContextualResourceModel> mockResourceModel = CreateMockResourceModel();
            IEnvironmentModel        environmentModel;
            IExplorerItemModel       resourceVm;
            IExplorerItemModel       rootItem;
            StudioResourceRepository studioResourceRepository = CreateModels(false, mockResourceModel, out environmentModel, out resourceVm, out rootItem);

            Mock <IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(Studio.Core.AppResources.Enums.ResourceType.WorkflowService, Guid.NewGuid());



            environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>(), new List <IResourceModel>()).Object;

            var navigationViewModel = CreateDeployNavigationViewModel(environmentModel, studioResourceRepository);

            resourceVm.IsChecked = true;
            bool actual = DeployStatsCalculator.DeploySummaryPredicateExisting(null, navigationViewModel);

            Assert.IsFalse(actual);
        }
Ejemplo n.º 16
0
        protected StudioResourceRepository CreateModels(bool isChecked, Mock <IContextualResourceModel> mockResourceModel, out IEnvironmentModel environmentModel, out IExplorerItemModel resourceVm, out IExplorerItemModel rootItem)
        {
            Mock <IContextualResourceModel> resourceModel = mockResourceModel;

            var connection = new Mock <IEnvironmentConnection>();

            var mockEnvironmentModel = new Mock <IEnvironmentModel>();

            mockEnvironmentModel.Setup(e => e.Connection).Returns(connection.Object);
            mockEnvironmentModel.Setup(a => a.AuthorizationService).Returns(new Mock <IAuthorizationService>().Object);
            environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List <IResourceModel>()).Object;

            var serverItemModel = new ExplorerItemModel {
                DisplayName = "localhost", ResourceType = ResourceType.Server, EnvironmentId = environmentModel.ID, ResourcePath = "", ResourceId = Guid.NewGuid()
            };

            rootItem = serverItemModel;
            ExplorerItemModel workflowsFolder = new ExplorerItemModel {
                DisplayName = "WORKFLOWS", ResourceType = ResourceType.Folder, ResourcePath = "WORKFLOWS", EnvironmentId = mockEnvironmentModel.Object.ID, ResourceId = Guid.NewGuid()
            };

            serverItemModel.Children.Add(workflowsFolder);

            var studioResourceRepository = new StudioResourceRepository(serverItemModel, _Invoke);

            resourceModel.Setup(model => model.Category).Returns("WORKFLOWS\\" + resourceModel.Object.DisplayName);
            resourceModel.Setup(a => a.ID).Returns(resourceIdConflict);
            TestEnvironmentRespository testEnvironmentRespository = new TestEnvironmentRespository(environmentModel);

            // ReSharper disable ObjectCreationAsStatement
            new EnvironmentRepository(testEnvironmentRespository);
            // ReSharper restore ObjectCreationAsStatement
            IEnvironmentModel internalEnvironmentModel = environmentModel;

            studioResourceRepository.GetCurrentEnvironment = () => internalEnvironmentModel.ID;
            studioResourceRepository.AddResouceItem(resourceModel.Object);
            resourceVm           = workflowsFolder.Children[0];
            resourceVm.IsChecked = isChecked;
            return(studioResourceRepository);
        }