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); } }
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); }
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 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); }
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 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 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 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 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 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------------------------- }
public override IList <IToolRegion> BuildRegions() { IList <IToolRegion> regions = new List <IToolRegion>(); if (SourceRegion == null) { SourceRegion = new DotNetSourceRegion(Model, ModelItem) { SourceChangedAction = () => { OutputsRegion.IsEnabled = false; if (Regions != null) { foreach (var toolRegion in Regions) { toolRegion.Errors?.Clear(); } } } }; regions.Add(SourceRegion); NamespaceRegion = new DotNetNamespaceRegion(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 DotNetActionRegion(Model, ModelItem, SourceRegion, NamespaceRegion) { SourceChangedAction = () => { OutputsRegion.IsEnabled = false; if (Regions != null) { foreach (var toolRegion in Regions) { toolRegion.Errors?.Clear(); } } } }; ActionRegion.ErrorsHandler += (sender, list) => { List <ActionableErrorInfo> 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); }