예제 #1
0
        public void CloneRegionExpectClone()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };
            var s2 = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));
            var cloned = region.CloneRegion();

            Assert.AreEqual(((WebSourceRegion)cloned).SelectedSource, region.SelectedSource);
        }
예제 #2
0
        public void Restore_Region_ExpectRestore()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };
            var s2 = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            var regionToRestore = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            regionToRestore.SelectedSource = s2;

            region.RestoreRegion(regionToRestore);

            Assert.AreEqual(region.SelectedSource, s2);
        }
예제 #3
0
        public override IList <IToolRegion> BuildRegions()
        {
            IList <IToolRegion> regions = new List <IToolRegion>();

            if (SourceRegion == null)
            {
                SourceRegion = new WebSourceRegion(Model, ModelItem)
                {
                    SourceChangedAction = () => { OutputsRegion.IsEnabled = false; }
                };
                regions.Add(SourceRegion);
                InputArea = new WebGetInputRegion(ModelItem, SourceRegion);
                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(InputArea);
                SourceRegion.Dependants.Add(OutputsRegion);
            }
            regions.Add(ManageServiceInputViewModel);
            Regions = regions;
            return(regions);
        }
예제 #4
0
        public override IList <IToolRegion> BuildRegions()
        {
            IList <IToolRegion> regions = new List <IToolRegion>();

            if (SourceRegion == null)
            {
                SourceRegion = new WebSourceRegion(Model, ModelItem)
                {
                    SourceChangedAction = () => { OutputsRegion.IsEnabled = false; }
                };
                regions.Add(SourceRegion);
                InputArea = new WebPostInputRegion(ModelItem, SourceRegion);
                InputArea.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName == "PostData" && InputArea.Headers.All(value => string.IsNullOrEmpty(value.Name)))
                    {
                        ((ManageWebServiceInputViewModel)ManageServiceInputViewModel).BuidHeaders(InputArea.PostData);
                    }
                };
                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(InputArea);
                SourceRegion.Dependants.Add(OutputsRegion);
            }
            regions.Add(ManageServiceInputViewModel);
            Regions = regions;
            return(regions);
        }
예제 #5
0
        public void WebInputRegion_RestoreFromPrevios_Restore_ExpectValuesChanged()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfWebPostActivity()
            {
                SourceId = id
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            WebSourceRegion srcreg          = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPostActivity()));
            var             region          = new WebPostInputRegion(ModelItemUtils.CreateModelItem(act), srcreg);
            var             regionToRestore = new WebPostInputRegionClone
            {
                IsEnabled   = true,
                QueryString = "blob",
                Headers     = new ObservableCollection <INameValue> {
                    new NameValue("a", "b")
                }
            };

            //------------Execute Test---------------------------
            region.RestoreRegion(regionToRestore);
            //------------Assert Results-------------------------

            Assert.AreEqual(region.QueryString, "blob");
            Assert.AreEqual(region.Headers.First().Name, "a");
            Assert.AreEqual(region.Headers.First().Value, "b");
        }
예제 #6
0
        public void WebInputRegion_SrcChanged_UpdateValues()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfWebPostActivity()
            {
                SourceId = id
            };

            var mod = new Mock <IWebServiceModel>();
            var lst = new List <IWebServiceSource> {
                new WebServiceSourceDefinition()
                {
                    HostName = "bob", DefaultQuery = "Dave"
                }, new WebServiceSourceDefinition()
                {
                    HostName = "f", DefaultQuery = "g"
                }
            };

            mod.Setup(a => a.RetrieveSources()).Returns(lst);
            WebSourceRegion srcreg = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPostActivity()));
            var             region = new WebPostInputRegion(ModelItemUtils.CreateModelItem(act), srcreg);

            srcreg.SelectedSource = lst[0];
            Assert.AreEqual(region.QueryString, "Dave");
            Assert.AreEqual(region.RequestUrl, "bob");
        }
예제 #7
0
        public void TestClone()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebPostActivity()
            {
                SourceId = id
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            WebSourceRegion srcreg = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPostActivity()));
            var             region = new WebPostInputRegion(ModelItemUtils.CreateModelItem(act), srcreg)
            {
                PostData = "bob"
            };

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

            if (clone != null)
            {
                Assert.AreEqual(clone.IsEnabled, false);
                Assert.AreEqual(clone.Errors.Count, 0);
                Assert.AreEqual(clone.PostData, "bob");
            }
        }
예제 #8
0
        public void WebPutInputRegion_TestClone_IsPutDataBase64()
        {
            var id  = Guid.NewGuid();
            var act = new WebPutActivity
            {
                SourceId = id
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var webSourceRegion = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new WebPutActivity()));
            var region          = new WebPutInputRegion(ModelItemUtils.CreateModelItem(act), webSourceRegion)
            {
                PutData = "bob", IsPutDataBase64 = true
            };

            Assert.AreEqual(region.IsEnabled, false);
            Assert.AreEqual(region.Errors.Count, 0);
            if (region.CloneRegion() is WebPutInputRegion clone)
            {
                Assert.AreEqual(clone.IsEnabled, false);
                Assert.AreEqual(clone.Errors.Count, 0);
                Assert.AreEqual(clone.PutData, "bob");
                Assert.IsTrue(clone.IsPutDataBase64);
            }
        }
예제 #9
0
        public void WebPutInputRegion_Headers_AddEmptyHeaders()
        {
            //------------Setup for test--------------------------
            var id             = Guid.NewGuid();
            var webPutActivity = new DsfWebPutActivity
            {
                SourceId = id,
                Headers  = new ObservableCollection <INameValue> {
                    new NameValue("a", "b")
                },
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());

            var modelItem = ModelItemUtils.CreateModelItem(webPutActivity);

            var webSourceRegion = new WebSourceRegion(mod.Object, modelItem);
            var region          = new WebPutInputRegion(modelItem, webSourceRegion);

            //------------Execute Test---------------------------

            //------------Assert Results-------------------------

            Assert.AreEqual(2, region.Headers.Count);
            Assert.AreEqual("a", region.Headers[0].Name);
            Assert.AreEqual("b", region.Headers[0].Value);
            Assert.AreEqual("", region.Headers[1].Name);
            Assert.AreEqual("", region.Headers[1].Value);
        }
예제 #10
0
        public void WebPostInputRegion_Settings_SetIsFormDataChecked_WebPostActivity()
        {
            //------------Setup for test--------------------------
            var id = Guid.NewGuid();

#pragma warning disable 618
            var webPostActivity = new WebPostActivity()
#pragma warning restore 618
            {
                SourceId = id,
                Headers  = new ObservableCollection <INameValue> {
                    new NameValue("a", "b")
                },
            };

            var mod = new Mock <IWebServiceModel>();
            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());

            var modelItem = ModelItemUtils.CreateModelItem(webPostActivity);

            var webSourceRegion = new WebSourceRegion(mod.Object, modelItem);
            var region          = new WebPostInputRegion(modelItem, webSourceRegion)
            {
                ViewModel = new WebPostActivityViewModel(modelItem, GetMockModel())
            };
            region.IsFormDataChecked = true;
            //------------Execute Test---------------------------

            //------------Assert Results-------------------------

            Assert.IsNull(region?.Settings?.FirstOrDefault(s => s.Name == "IsUrlEncodedChecked")?.Value);
            Assert.IsNull(region?.Settings?.FirstOrDefault(s => s.Name == "IsFormDataChecked")?.Value);
            Assert.IsNull(region?.Settings?.FirstOrDefault(s => s.Name == "IsManualChecked")?.Value);
        }
예제 #11
0
        public void ChangeSrcExpectSomethingChanged()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };
            var Evt = false;
            var s2  = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            region.SomethingChanged += (a, b) => { Evt = true; };
            region.SelectedSource    = s2;
            Assert.IsTrue(Evt);
        }
예제 #12
0
        ISourceToolRegion <IWebServiceSource> CreateWebSourceRegion()
        {
            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var srcreg = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPutActivity()));

            return(srcreg);
        }
예제 #13
0
        public void Ctor()
        {
            var src = new Mock <IWebServiceModel>();

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfWebGetActivity()));

            Assert.AreEqual(1, region.Errors.Count);
            Assert.IsTrue(region.IsEnabled);
        }
예제 #14
0
        public void TestInputCtorEmpty()
        {
            var act = CreatePutActivity();
            var src = new Mock <IWebServiceSource>();

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var srcreg = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPutActivity()));
            var region = new WebPostInputRegion();

            Assert.AreEqual(region.IsEnabled, false);
        }
예제 #15
0
        public void WebPutInputRegion_TestInputCtor()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebPutActivity {
                SourceId = id
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var webSourceRegion = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebPutActivity()));
            var region          = new WebPutInputRegion(ModelItemUtils.CreateModelItem(act), webSourceRegion);

            Assert.AreEqual(false, region.IsEnabled);
            Assert.AreEqual(0, region.Errors.Count);
        }
예제 #16
0
        public void TestInputCtor()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebDeleteActivity()
            {
                SourceId = id
            };
            var src = new Mock <IWebServiceSource>();

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var srcreg = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebDeleteActivity()));
            var region = new WebDeleteInputRegion(ModelItemUtils.CreateModelItem(act), srcreg);

            Assert.AreEqual(region.IsEnabled, false);
            Assert.AreEqual(region.Errors.Count, 0);
        }
예제 #17
0
        public void WebDeleteInputRegion_TestClone()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebDeleteActivity {
                SourceId = id
            };

            var mod = new Mock <IWebServiceModel>();

            mod.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource>());
            var webSourceRegion = new WebSourceRegion(mod.Object, ModelItemUtils.CreateModelItem(new DsfWebDeleteActivity()));
            var region          = new WebDeleteInputRegion(ModelItemUtils.CreateModelItem(act), webSourceRegion);

            Assert.AreEqual(region.IsEnabled, false);
            Assert.AreEqual(region.Errors.Count, 0);
            if (region.CloneRegion() is WebDeleteInputRegion clone)
            {
                Assert.AreEqual(clone.IsEnabled, false);
                Assert.AreEqual(clone.Errors.Count, 0);
            }
        }
예제 #18
0
        public void CtorWitSelectedSrc()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc
            });
            var region = new WebSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act));

            Assert.AreEqual(websrc, region.SelectedSource);
            Assert.IsTrue(region.CanEditSource());
        }
예제 #19
0
        public void ChangeSelectedSource_ExpectRegionsRestored()
        {
            var id  = Guid.NewGuid();
            var act = new DsfWebGetActivity()
            {
                SourceId = id
            };
            var src    = new Mock <IWebServiceModel>();
            var websrc = new WebServiceSourceDefinition()
            {
                Id = id, HostName = "bob"
            };

            var s2 = new WebServiceSourceDefinition()
            {
                Id = Guid.NewGuid(), HostName = "bob"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new List <IWebServiceSource> {
                websrc, s2
            });
            var region = new WebSourceRegion(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 = websrc;
            dep1.Verify(a => a.RestoreRegion(clone1.Object));
            dep2.Verify(a => a.RestoreRegion(clone2.Object));
        }