Exemple #1
0
        public void DotNetSourceRegion_ConstructorWithSelectedSource_Scenerio_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var pluginSrc = new PluginSourceDefinition()
            {
                Id = id
            };

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

            //------------Execute Test---------------------------
            var region = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            //------------Assert Results-------------------------
            Assert.AreEqual(pluginSrc, region.SelectedSource);
            Assert.IsTrue(region.CanEditSource());
        }
Exemple #2
0
        public void DotNetSourceRegion_ChangeSourceSomethingChanged_ExpectedChange_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var pluginSrc = new PluginSourceDefinition()
            {
                Id = id
            };
            var evt = false;
            var s2  = new PluginSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                pluginSrc, s2
            });

            //------------Execute Test---------------------------
            var region = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            region.SomethingChanged += (a, b) => { evt = true; };
            region.SelectedSource    = s2;

            //------------Assert Results-------------------------
            Assert.IsTrue(evt);
        }
        public void DotNetActionRegion_Constructor_Scenerio_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                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 DsfPluginActivity()));

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            DotNetNamespaceRegion dotNetNamespaceRegion = new DotNetNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            dotNetNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            DotNetActionRegion dotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfPluginActivity()), sourceRegion, dotNetNamespaceRegion);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, dotNetActionRegion.Errors.Count);
            Assert.IsTrue(dotNetActionRegion.IsEnabled);
        }
Exemple #4
0
        public void DotNetSourceRegion_ChangeSourceSomethingChanged_CloneRegion_ExpectedClone()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var pluginSrc = new PluginSourceDefinition()
            {
                Id = id
            };
            var s2 = new PluginSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                pluginSrc, s2
            });

            //------------Execute Test---------------------------
            var region = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));
            var cloned = region.CloneRegion();

            //------------Assert Results-------------------------
            Assert.AreEqual(cloned.IsEnabled, region.IsEnabled);
            Assert.AreEqual(((DotNetSourceRegion)cloned).SelectedSource, region.SelectedSource);
        }
Exemple #5
0
        public void DotNetNamespaceRegion_ConstructorWithSelectedNamespace_Scenerio_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var pluginSrc = new PluginSourceDefinition()
            {
                Id = id, Name = "johnny"
            };
            var namespaceItem = new NamespaceItem {
                FullName = "bravo"
            };

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

            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfPluginActivity()));

            sourceRegion.SelectedSource = pluginSrc;

            //------------Execute Test---------------------------
            DotNetNamespaceRegion dotNetNamespaceRegion = new DotNetNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            dotNetNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Assert Results-------------------------
            Assert.AreEqual(namespaceItem, dotNetNamespaceRegion.SelectedNamespace);
            Assert.IsTrue(dotNetNamespaceRegion.CanRefresh());
        }
        public void DotNetActionRegion_ChangeActionSomethingChanged_RegionsNotRestored_Invalid()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var dotNetsrc = new PluginSourceDefinition()
            {
                Id = id
            };
            var action = new PluginAction {
                FullName = "bravo"
            };

            var s2 = new PluginSourceDefinition {
                Id = Guid.NewGuid()
            };
            var action1 = new PluginAction {
                FullName = "bravo1"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                dotNetsrc, s2
            });

            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfPluginActivity()));

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            DotNetNamespaceRegion dotNetNamespaceRegion = new DotNetNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            dotNetNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            DotNetActionRegion dotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, dotNetNamespaceRegion);

            var clone1 = new Mock <IToolRegion>();
            var clone2 = new Mock <IToolRegion>();
            var dep1   = new Mock <IToolRegion>();

            dep1.Setup(a => a.CloneRegion()).Returns(clone1.Object);

            var dep2 = new Mock <IToolRegion>();

            dep2.Setup(a => a.CloneRegion()).Returns(clone2.Object);
            dotNetActionRegion.Dependants = new List <IToolRegion> {
                dep1.Object, dep2.Object
            };
            dotNetActionRegion.SelectedAction = action;
            dotNetActionRegion.SelectedAction = action1;

            //------------Assert Results-------------------------
            dep1.Verify(a => a.RestoreRegion(clone1.Object), Times.Never);
            dep2.Verify(a => a.RestoreRegion(clone2.Object), Times.Never);
        }
Exemple #7
0
        public void ModelItemToActivityConverter_ConvertBack_PluginActivity()
        {
            var converter = new ModelItemToActivityConverter();

            var mockModelItem  = new Mock <ModelItem>();
            var pluginActivity = new DsfPluginActivity();

            mockModelItem.Setup(o => o.GetCurrentValue()).Returns(pluginActivity);
            var actual = converter.ConvertBack(mockModelItem.Object, null, null, null);

            Assert.AreEqual(pluginActivity, actual);
        }
Exemple #8
0
        public void DotNetSourceRegion_ChangeSourceSomethingChanged_RegionsNotRestored_Invalid()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var pluginSrc = new PluginSourceDefinition()
            {
                Id = id
            };

            var s2 = new PluginSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                pluginSrc, s2
            });

            //------------Execute Test---------------------------
            var region = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            var clone1 = new Mock <IToolRegion>();
            var clone2 = new Mock <IToolRegion>();
            var dep1   = new Mock <IToolRegion>();

            dep1.Setup(a => a.CloneRegion()).Returns(clone1.Object);

            var dep2 = new Mock <IToolRegion>();

            dep2.Setup(a => a.CloneRegion()).Returns(clone2.Object);
            region.Dependants = new List <IToolRegion> {
                dep1.Object, dep2.Object
            };
            region.SelectedSource = s2;
            region.SelectedSource = pluginSrc;

            //------------Assert Results-------------------------
            dep1.Verify(a => a.RestoreRegion(clone1.Object), Times.Never);
            dep2.Verify(a => a.RestoreRegion(clone2.Object), Times.Never);
        }
        public void DotNetActionRegion_ChangeActionSomethingChanged_RestoreRegion_ExpectedRestore()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var dotNetsrc = new PluginSourceDefinition {
                Id = id
            };
            var s2 = new PluginSourceDefinition {
                Id = Guid.NewGuid()
            };
            var action = new PluginAction {
                FullName = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                dotNetsrc, s2
            });

            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfPluginActivity()));

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            DotNetNamespaceRegion dotNetNamespaceRegion = new DotNetNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            dotNetNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            DotNetActionRegion dotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, dotNetNamespaceRegion);
            // ReSharper disable once UseObjectOrCollectionInitializer
            DotNetActionRegion dotNetActionRegionToRestore = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, dotNetNamespaceRegion);

            dotNetActionRegionToRestore.IsEnabled      = false;
            dotNetActionRegionToRestore.SelectedAction = action;

            dotNetActionRegion.RestoreRegion(dotNetActionRegionToRestore);

            //------------Assert Results-------------------------
            Assert.AreEqual(dotNetActionRegion.SelectedAction, action);
            Assert.IsFalse(dotNetActionRegion.IsEnabled);
        }
        public void DotNetActionRegion_ConstructorWithSelectedAction_Scenerio_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var dotNetsrc = new PluginSourceDefinition {
                Id = id, Name = "johnny"
            };
            var action = new PluginAction {
                FullName = "bravo", Method = "bravo", ReturnType = typeof(string), Variables = new List <INameValue>()
            };

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

            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfPluginActivity()));

            sourceRegion.SelectedSource = dotNetsrc;

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            DotNetNamespaceRegion dotNetNamespaceRegion = new DotNetNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            dotNetNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            DotNetActionRegion dotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, dotNetNamespaceRegion);

            dotNetActionRegion.SelectedAction = action;

            //------------Assert Results-------------------------
            Assert.AreEqual(action, dotNetActionRegion.SelectedAction);
            Assert.AreEqual(action.FullName, dotNetActionRegion.SelectedAction.FullName);
            Assert.AreEqual(action.Method, dotNetActionRegion.SelectedAction.Method);
            Assert.AreEqual(typeof(string), dotNetActionRegion.SelectedAction.ReturnType);
            Assert.AreEqual(0, dotNetActionRegion.SelectedAction.Variables.Count);
            Assert.IsTrue(dotNetActionRegion.CanRefresh());
        }
        public void DotNetActionRegion_ChangeActionSomethingChanged_ExpectedChange_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var dotNetsrc = new PluginSourceDefinition {
                Id = id
            };
            var evt = false;
            var s2  = new PluginSourceDefinition()
            {
                Id = Guid.NewGuid()
            };
            var action = new PluginAction {
                FullName = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                dotNetsrc, s2
            });

            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfPluginActivity()));

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            DotNetNamespaceRegion dotNetNamespaceRegion = new DotNetNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            dotNetNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            DotNetActionRegion dotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, dotNetNamespaceRegion);

            dotNetActionRegion.SomethingChanged += (a, b) => { evt = true; };
            dotNetActionRegion.SelectedAction    = action;

            //------------Assert Results-------------------------
            Assert.IsTrue(evt);
        }
        public static DsfActivity CreateDsfActivity(IContextualResourceModel resource, DsfActivity activity,
                                                    bool ifNullCreateNew, IServerRepository serverRepository, bool isDesignerLocalhost)
        {
            var activityToUpdate = activity;

            if (activityToUpdate == null)
            {
                if (ifNullCreateNew)
                {
                    if (resource.ServerResourceType == "WebService")
                    {
                        activityToUpdate = new DsfWebserviceActivity();
                    }
                    else if (resource.ServerResourceType == "PluginService")
                    {
                        activityToUpdate = new DsfPluginActivity();
                    }
                    else if (resource.ServerResourceType == "DbService")
                    {
                        activityToUpdate = new DsfDatabaseActivity();
                    }
                    else
                    {
                        activityToUpdate = new DsfActivity();
                    }
                }
                else
                {
                    return(null);
                }
            }

            if (resource != null)
            {
                var activeEnvironment = serverRepository.ActiveServer;
                activityToUpdate.ResourceID = resource.ID;
                SetCorrectEnvironmentId(resource, activityToUpdate, isDesignerLocalhost, activeEnvironment);
                activityToUpdate = SetActivityProperties(resource, activityToUpdate);
            }

            activityToUpdate.ExplicitDataList = null;
            return(activityToUpdate);
        }
Exemple #13
0
        public void GetNamespaces_GivenHasError_ShouldAddIntoErrors()
        {
            //---------------Set up test pack-------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var pluginSrc = new PluginSourceDefinition()
            {
                Id = id
            };
            var s2 = new PluginSourceDefinition()
            {
                Id = Guid.NewGuid()
            };
            var namespaceItem = new NamespaceItem {
                FullName = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                pluginSrc, s2
            });
            src.Setup(a => a.GetNameSpaces(It.IsAny <IPluginSource>())).Throws(new BadImageFormatException());

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var modelItem = ModelItemUtils.CreateModelItem(new DsfPluginActivity());
            DotNetSourceRegion dotNetSourceRegion = new DotNetSourceRegion(src.Object, modelItem);
            var mockPluginSource = new Mock <IPluginSource>();

            dotNetSourceRegion.SelectedSource = mockPluginSource.Object;
            DotNetNamespaceRegion sourceRegion = new DotNetNamespaceRegion(src.Object, modelItem, dotNetSourceRegion);

            //---------------Test Result -----------------------
            Assert.AreEqual(sourceRegion.Errors.Count, 1);
            Assert.AreEqual(sourceRegion.Errors.Count(s => s.Contains("Format of the executable (.exe) or library (.dll) is invalid")), 1);
        }
        public void DotNetActionRegion_ChangeActionSomethingChanged_CloneRegion_ExpectedClone()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var dotNetsrc = new PluginSourceDefinition {
                Id = id
            };
            var s2 = new PluginSourceDefinition {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                dotNetsrc, s2
            });

            DotNetSourceRegion sourceRegion = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfPluginActivity()));

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            DotNetNamespaceRegion dotNetNamespaceRegion = new DotNetNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            dotNetNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            DotNetActionRegion dotNetActionRegion = new DotNetActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, dotNetNamespaceRegion);
            var cloned = dotNetActionRegion.CloneRegion();

            //------------Assert Results-------------------------
            Assert.AreEqual(cloned.IsEnabled, dotNetActionRegion.IsEnabled);
            Assert.AreEqual(((DotNetActionRegion)cloned).SelectedAction, dotNetActionRegion.SelectedAction);
        }
        public void DotNetSourceRegion_ChangeSourceSomethingChanged_RestoreRegion_ExpectedRestore()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfPluginActivity()
            {
                SourceId = id
            };
            var src       = new Mock <IPluginServiceModel>();
            var pluginSrc = new PluginSourceDefinition()
            {
                Id = id
            };
            var s2 = new PluginSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IPluginSource>()
            {
                pluginSrc, s2
            });

            //------------Execute Test---------------------------
            DotNetSourceRegion region = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));
            // ReSharper disable once UseObjectOrCollectionInitializer
            DotNetSourceRegion regionToRestore = new DotNetSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            regionToRestore.IsEnabled      = false;
            regionToRestore.SelectedSource = s2;

            region.RestoreRegion(regionToRestore);

            //------------Assert Results-------------------------
            Assert.AreEqual(region.SelectedSource, s2);
            Assert.IsFalse(region.IsEnabled);
        }