public void DotNetInputRegion_SourceChanged_UpdateValues()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var src = new Mock <IPluginServiceModel>();

            var lst = new ObservableCollection <IPluginSource>()
            {
                new PluginSourceDefinition()
                {
                    Name = "bravo"
                }, new PluginSourceDefinition()
                {
                    Name = "johnny"
                }
            };

            src.Setup(a => a.RetrieveSources()).Returns(lst);
            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()));
            var nameSpace = new Mock <INamespaceToolRegion <INamespaceItem> >();
            DotNetActionRegion DotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()), sourceRegion, nameSpace.Object);

            var region = new DotNetInputRegion(ModelItemUtils.CreateModelItem(act), DotNetActionRegion);

            sourceRegion.SelectedSource = lst[0];
            Assert.AreEqual(region.Inputs.Count, 0);
        }
        public void DotNetInputRegion_TestClone()
        {
            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var nameSpace = new Mock <INamespaceToolRegion <INamespaceItem> >();

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>());
            DotNetSourceRegion sourceRegion       = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()));
            DotNetActionRegion DotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()), sourceRegion, nameSpace.Object);

            var region = new DotNetInputRegion(ModelItemUtils.CreateModelItem(act), DotNetActionRegion);

            Assert.AreEqual(region.IsEnabled, false);
            Assert.AreEqual(region.Errors.Count, 0);
            var clone = region.CloneRegion() as DotNetInputRegion;

            if (clone != null)
            {
                Assert.AreEqual(clone.IsEnabled, false);
                Assert.AreEqual(clone.Errors.Count, 0);
            }
        }
Esempio n. 3
0
        public override IList <IToolRegion> BuildRegions()
        {
            IList <IToolRegion> regions = new List <IToolRegion>();

            if (SourceRegion == null)
            {
                AddSourceRegion(regions);
                AddNamespaceRegion(regions);
                AddActionRegion(regions);
                InputArea = new DotNetInputRegion(ModelItem, ActionRegion);
                regions.Add(InputArea);
                OutputsRegion = new OutputsRegion(ModelItem, true);
                regions.Add(OutputsRegion);
                if (OutputsRegion.Outputs.Count > 0)
                {
                    OutputsRegion.IsEnabled = true;
                }
                ErrorRegion = new ErrorRegion();
                regions.Add(ErrorRegion);
                SourceRegion.Dependants.Add(NamespaceRegion);
                NamespaceRegion.Dependants.Add(ActionRegion);
                ActionRegion.Dependants.Add(InputArea);
                ActionRegion.Dependants.Add(OutputsRegion);
            }
            regions.Add(ManageServiceInputViewModel);
            Regions = regions;
            return(regions);
        }
        public void DotNetInputRegion_Constructor_TestInput_ConstructorEmpty()
        {
            var src = new Mock <IPluginServiceModel>();

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>());

            var region = new DotNetInputRegion();

            Assert.AreEqual(region.IsEnabled, false);
        }
        public void UpdateOnActionSelection_GivenHasInputsWithDataTypes_ShouldWriteToActiveDatalistAndPopulatesInputValues()
        {
            //---------------Set up test pack-------------------
            var eventAggregator = new Mock <IEventAggregator>();

            var mockResourceModel = Dev2MockFactory.SetupResourceModelMock();

            mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest());

            var dataListViewModel  = CreateDataListViewModel(mockResourceModel, eventAggregator.Object);
            var dataListItems      = new OptomizedObservableCollection <IScalarItemModel>();
            var dataListItem       = new ScalarItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty);
            var secondDataListItem = new ScalarItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty);

            dataListItems.Add(dataListItem);
            dataListItems.Add(secondDataListItem);

            DataListSingleton.SetDataList(dataListViewModel);



            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var modelItem    = ModelItemUtils.CreateModelItem(act);
            var actionRegion = new Mock <IActionToolRegion <IPluginAction> >();

            actionRegion.Setup(region => region.SelectedAction).Returns(ValueFunctionWithTypes);

            //---------------Assert Precondition----------------

            var countBefore = DataListSingleton.ActiveDataList.ScalarCollection.Count;

            Assert.AreEqual(4, countBefore);
            //---------------Execute Test ----------------------
            var inputRegion = new DotNetInputRegion(modelItem, actionRegion.Object);

            var methodInfo = typeof(DotNetInputRegion).GetMethod("UpdateOnActionSelection", BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.IsNotNull(methodInfo);
            methodInfo.Invoke(inputRegion, new object[] { });
            //---------------Test Result -----------------------
            Assert.AreEqual("[[name]]", inputRegion.Inputs.ToList()[0].Value);
            Assert.AreEqual("[[surname]]", inputRegion.Inputs.ToList()[1].Value);
        }
        public void DotNetInputRegion_Test_InputAddHeader_ExpectHeightChangesPastThree()
        {
            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var src = new Mock <IPluginServiceModel>();

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>());
            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()));
            var nameSpace = new Mock <INamespaceToolRegion <INamespaceItem> >();
            DotNetActionRegion DotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()), sourceRegion, nameSpace.Object);

            var region = new DotNetInputRegion(ModelItemUtils.CreateModelItem(act), DotNetActionRegion);

            Assert.AreEqual(region.IsEnabled, false);
        }
        public void DotNetInputRegion_Constructor_Scenerio_Result()
        {
            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var src = new Mock <IPluginServiceModel>();

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>());
            var nameSpace = new Mock <INamespaceToolRegion <INamespaceItem> >();

            var sourceRegion           = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()));
            var DotNetActionRegionInst = new DotNetActionRegion();

            var region = new DotNetInputRegion(ModelItemUtils.CreateModelItem(act), DotNetActionRegionInst);

            Assert.AreEqual(region.IsEnabled, false);
            Assert.AreEqual(region.Errors.Count, 0);
        }
        public void DotNetInputRegion_RestoreFromPrevious_Restore_ExpectValuesChanged()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var src = new Mock <IPluginServiceModel>();

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>());
            var nameSpace = new Mock <INamespaceToolRegion <INamespaceItem> >();
            DotNetSourceRegion sourceRegion       = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()));
            DotNetActionRegion DotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfDotNetDllActivity()), sourceRegion, nameSpace.Object);

            var region = new DotNetInputRegion(ModelItemUtils.CreateModelItem(act), DotNetActionRegion);
            // ReSharper disable once UseObjectOrCollectionInitializer
            var regionToRestore = new DotNetInputRegionClone();

            regionToRestore.IsEnabled = true;
            //------------Execute Test---------------------------
            region.RestoreRegion(regionToRestore);
            //------------Assert Results-------------------------
        }
Esempio n. 9
0
        public override IList <IToolRegion> BuildRegions()
        {
            IList <IToolRegion> regions = new List <IToolRegion>();

            if (SourceRegion == null)
            {
                SourceRegion = new ComSourceRegion(Model, ModelItem)
                {
                    SourceChangedAction = () =>
                    {
                        if (Regions != null)
                        {
                            foreach (var toolRegion in Regions)
                            {
                                toolRegion.Errors?.Clear();
                            }
                        }
                    }
                };
                regions.Add(SourceRegion);
                NamespaceRegion = new ComNamespaceRegion(Model, ModelItem, SourceRegion)
                {
                    SourceChangedNamespace = () =>
                    {
                        OutputsRegion.IsEnabled = false;
                        if (Regions != null)
                        {
                            foreach (var toolRegion in Regions)
                            {
                                toolRegion.Errors?.Clear();
                            }
                        }
                    }
                };
                NamespaceRegion.SomethingChanged += (sender, args) =>
                {
                    if (args.Errors != null)
                    {
                        Errors =
                            args.Errors.Select(e => new ActionableErrorInfo {
                            ErrorType = ErrorType.Critical, Message = e
                        } as IActionableErrorInfo)
                            .ToList();
                    }
                };
                regions.Add(NamespaceRegion);
                ActionRegion = new ComActionRegion(Model, ModelItem, SourceRegion, NamespaceRegion)
                {
                    SourceChangedAction = () =>
                    {
                        OutputsRegion.IsEnabled = false;
                        if (Regions != null)
                        {
                            foreach (var toolRegion in Regions)
                            {
                                toolRegion.Errors?.Clear();
                            }
                        }
                    }
                };
                ActionRegion.ErrorsHandler += (sender, list) =>
                {
                    var errorInfos = list.Select(error => new ActionableErrorInfo(new ErrorInfo {
                        ErrorType = ErrorType.Critical, Message = error
                    }, () => { })).ToList();
                    UpdateDesignValidationErrors(errorInfos);
                    Errors = new List <IActionableErrorInfo>(errorInfos);
                };
                regions.Add(ActionRegion);
                InputArea = new DotNetInputRegion(ModelItem, ActionRegion);
                regions.Add(InputArea);
                OutputsRegion = new OutputsRegion(ModelItem, true);
                regions.Add(OutputsRegion);
                if (OutputsRegion.Outputs.Count > 0)
                {
                    OutputsRegion.IsEnabled = true;
                }
                ErrorRegion = new ErrorRegion();
                regions.Add(ErrorRegion);
                SourceRegion.Dependants.Add(NamespaceRegion);
                NamespaceRegion.Dependants.Add(ActionRegion);
                ActionRegion.Dependants.Add(InputArea);
                ActionRegion.Dependants.Add(OutputsRegion);
            }
            regions.Add(ManageServiceInputViewModel);
            Regions = regions;
            return(regions);
        }