Example #1
0
        public void ManageWebServiceInputViewModel_TestActionSetSourceAndTestClickOk()
        {
            //------------Setup for test--------------------------
            var mod = new MyWebModel();

            var act = new DsfWebGetActivity();

            var webget    = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);
            var inputview = new ManageWebServiceInputViewModel(webget, mod);

            inputview.Model = new WebServiceDefinition();
            inputview.ExecuteTest();
            //------------Execute Test---------------------------
            Assert.IsTrue(inputview.InputArea.IsEnabled);
            Assert.IsTrue(inputview.OutputArea.IsEnabled);
            Assert.IsNotNull(inputview.OutputArea.Outputs);
            Assert.IsTrue(inputview.OutputArea.Outputs.Count > 0);

            inputview.ExecuteOk();
            //------------Execute Ok---------------------------
            Assert.IsTrue(webget.SourceRegion.IsEnabled);
            Assert.IsTrue(webget.OutputsRegion.IsEnabled);
            Assert.IsTrue(webget.InputArea.IsEnabled);
            Assert.IsTrue(webget.ErrorRegion.IsEnabled);
            Assert.IsFalse(webget.ManageServiceInputViewModel.InputArea.IsEnabled);

            //------------Assert Results-------------------------
        }
        public void Webget_TestActionSetSourceAndTestClickOkHasMappingsErrorFromServer()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();

            mod.HasRecError = true;
            var act = new DsfWebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            webget.ManageServiceInputViewModel = new InputViewForTest(webget, mod);
            webget.SourceRegion.SelectedSource = webget.SourceRegion.Sources.First();
#pragma warning disable 4014
            webget.TestInputCommand.Execute();
            webget.ManageServiceInputViewModel.TestCommand.Execute(null);
            webget.ManageServiceInputViewModel.IsEnabled          = true;
            webget.ManageServiceInputViewModel.OutputArea.Outputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c")
            };
            webget.ManageServiceInputViewModel.OkCommand.Execute(null);
#pragma warning restore 4014
            //------------Execute Test---------------------------

            Assert.IsTrue(webget.ErrorRegion.IsEnabled);

            //------------Assert Results-------------------------
        }
Example #3
0
        public void ManageWebServiceInputViewModel_TestActionSetSourceAndTest_ExistingContent()
        {
            //------------Setup for test--------------------------
            var mod = new MyModel()
            {
                Response = "{\"NormalText\":\"\"}"
            };

            var act = new DsfWebGetActivity()
            {
                Headers = new List <INameValue>()
                {
                    new NameValue("Content-Type", "Application/xml")
                }
            };

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            var inputview = new ManageWebServiceInputViewModel(webget, mod);

            inputview.Model = new WebServiceDefinition();
            Assert.AreEqual(2, webget.InputArea.Headers.Count);
            //------------Execute Test---------------------------
            inputview.ExecuteTest();
            //------------Assert Results-------------------------
            Assert.IsTrue(inputview.InputArea.IsEnabled);
            Assert.IsTrue(inputview.OutputArea.IsEnabled);
            Assert.IsNotNull(inputview.OutputArea.Outputs);
            Assert.IsTrue(inputview.OutputArea.Outputs.Count > 0);
            Assert.AreEqual(2, webget.InputArea.Headers.Count);
        }
Example #4
0
        public void ManageWebServiceInputViewModel_Ctor()
        {
            var mod = new MyWebModel();
            var act = new DsfWebGetActivity()
            {
                SourceId = mod.Sources[0].Id,
                Outputs  = new List <IServiceOutputMapping> {
                    new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("d", "e", "f")
                },
                Headers = new List <INameValue> {
                    new NameValue("a", "x")
                },
                QueryString = "Bob the builder",
                ServiceName = "dsfBob"
            };

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            //------------Assert Results-------------------------
            ManageWebServiceInputViewModel vm = new ManageWebServiceInputViewModel(webget, mod);

            Assert.IsNotNull(vm.CloseCommand);
            Assert.IsNotNull(vm.PasteResponseCommand);
            Assert.IsNotNull(vm.CloseCommand);
        }
        public void Webget_TestActionSetSourceAndTestClickOkHasQueryStringAndHeadersRecSet()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();
            var act = new DsfWebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            webget.ManageServiceInputViewModel = new InputViewForTest(webget, mod);
            webget.SourceRegion.SelectedSource = webget.SourceRegion.Sources.First();
            webget.InputArea.Headers.Add(new NameValue("[[a]]", "asa"));
            webget.InputArea.QueryString = "the [[b().a]]";
#pragma warning disable 4014
            webget.TestInputCommand.Execute();
            webget.ManageServiceInputViewModel.TestCommand.Execute(null);
            webget.ManageServiceInputViewModel.IsEnabled          = true;
            webget.ManageServiceInputViewModel.OutputArea.Outputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c")
            };
            webget.ManageServiceInputViewModel.OkCommand.Execute(null);
#pragma warning restore 4014
            //------------Execute Test---------------------------
            Assert.IsTrue(webget.SourceRegion.IsEnabled);
            Assert.IsTrue(webget.OutputsRegion.IsEnabled);
            Assert.IsTrue(webget.InputArea.IsEnabled);
            Assert.IsTrue(webget.ErrorRegion.IsEnabled);
            Assert.IsTrue(webget.ManageServiceInputViewModel.InputArea.Inputs.Count == 2);
            Assert.IsTrue(webget.ManageServiceInputViewModel.InputArea.Inputs.First().Name == "[[b().a]]");
            Assert.IsTrue(webget.ManageServiceInputViewModel.InputArea.Inputs.Last().Name == "[[a]]");
            Assert.AreEqual(0, webget.ManageServiceInputViewModel.Errors.Count);
            //------------Assert Results-------------------------
        }
        public void Webget_TestActionSetSourceAndTestClickOkHasserialisationIssue()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();

            mod.IsTextResponse = true;
            var act = new DsfWebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            webget.ManageServiceInputViewModel = new InputViewForTest(webget, mod);
            webget.SourceRegion.SelectedSource = webget.SourceRegion.Sources.First();
#pragma warning disable 4014
            webget.TestInputCommand.Execute();
            webget.ManageServiceInputViewModel.TestCommand.Execute(null);
            webget.ManageServiceInputViewModel.IsEnabled = true;
            webget.ManageServiceInputViewModel.OkCommand.Execute(null);
#pragma warning restore 4014
            //------------Execute Test---------------------------

            Assert.AreEqual(webget.OutputsRegion.Outputs.First().MappedFrom, "Result");

            //------------Assert Results-------------------------
        }
        public void Webget_TestActionSetSource()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();
            var act = new DsfWebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            webget.ManageServiceInputViewModel = new InputViewForTest(webget, mod);
            webget.SourceRegion.SelectedSource = webget.SourceRegion.Sources.First();
            webget.SourceRegion.SelectedSource.AuthenticationType = AuthenticationType.Public;
            webget.SourceRegion.SelectedSource.UserName           = "";
            webget.SourceRegion.SelectedSource.Password           = "";
            webget.SourceRegion.SelectedSource.Path = "";
            //------------Execute Test---------------------------
            var hashCode = webget.SourceRegion.SelectedSource.GetHashCode();

            Assert.IsTrue(webget.SourceRegion.IsEnabled);
            Assert.IsFalse(webget.OutputsRegion.IsEnabled);
            Assert.IsTrue(webget.InputArea.IsEnabled);
            Assert.IsTrue(webget.ErrorRegion.IsEnabled);
            Assert.AreEqual("", webget.SourceRegion.SelectedSource.UserName);
            Assert.AreEqual("", webget.SourceRegion.SelectedSource.Password);
            Assert.AreEqual(AuthenticationType.Public, webget.SourceRegion.SelectedSource.AuthenticationType);
            Assert.AreEqual("", webget.SourceRegion.SelectedSource.Path);
            Assert.AreEqual(hashCode, webget.SourceRegion.SelectedSource.GetHashCode());
            //------------Assert Results-------------------------
        }
        public void ManageWebServiceInputViewModel_Properties()
        {
            var mod = new MyWebModel();
            var act = new WebGetActivity()
            {
                SourceId = mod.Sources[0].Id,
                Outputs  = new List <IServiceOutputMapping> {
                    new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("d", "e", "f")
                },
                Headers = new List <INameValue> {
                    new NameValue("a", "x")
                },
                QueryString = "Bob the builder",
                ServiceName = "dsfBob"
            };

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            var vm  = new ManageWebServiceInputViewModel(webget, mod);
            var lst = new List <IServiceInput>();

            vm.InputArea.Inputs = lst;
            Assert.AreEqual(lst.Count, vm.InputArea.Inputs.Count);
            var lsto = new List <IServiceOutputMapping>();

            vm.OutputArea.Outputs = lsto;
            Assert.AreEqual(lsto, vm.OutputArea.Outputs);
            vm.TestResults = "bob";
            Assert.AreEqual("bob", vm.TestResults);
            vm.TestResultsAvailable = true;
            Assert.IsTrue(vm.TestResultsAvailable);
            vm.OkSelected = true;
            Assert.IsTrue(vm.OkSelected);
            vm.IsTestResultsEmptyRows = true;
            Assert.IsTrue(vm.IsTestResultsEmptyRows);
            vm.IsTesting = true;
            Assert.IsTrue(vm.IsTesting);
            vm.PasteResponseVisible = true;
            Assert.IsTrue(vm.PasteResponseVisible);
            vm.PasteResponseAvailable = true;
            Assert.IsTrue(vm.PasteResponseAvailable);
            var b = new WebServiceDefinition()
            {
                Headers = new List <INameValue>()
                {
                    new NameValue("a", "b")
                }
            };

            vm.Model = b;
            Assert.IsNotNull(vm.Model);
        }
        public void Webget_MethodName_ClearErrors()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();
            var act = new WebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            //------------Execute Test---------------------------
            webget.ClearValidationMemoWithNoFoundError();
            //------------Assert Results-------------------------
            Assert.IsNull(webget.Errors);
            Assert.AreEqual(webget.DesignValidationErrors.Count, 1);
        }
        public void Webget_MethodName_ValidateExpectErrors()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();
            var act = new WebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            webget.Validate();
            //------------Execute Test---------------------------
            Assert.AreEqual(webget.Errors.Count, 1);
            Assert.AreEqual(webget.DesignValidationErrors.Count, 2);

            //------------Assert Results-------------------------
        }
Example #11
0
        public void ManageWebServiceInputViewModel_RestoreRegion_DoesNothing()
        {
            //------------Setup for test--------------------------
            var mod = new MyWebModel();

            var act       = new DsfWebGetActivity();
            var webget    = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);
            var inputview = new ManageWebServiceInputViewModel(webget, mod);

            inputview.Model = new WebServiceDefinition();

            //------------Execute Test---------------------------
            inputview.RestoreRegion(null);

            //------------Assert Results-------------------------
            Assert.IsTrue(true, "Error RestoreRegion should do nothing");
        }
Example #12
0
        public void ManageWebServiceInputViewModelCloneRegion_ReturnsNull()
        {
            //------------Setup for test--------------------------
            var mod = new MyWebModel();

            var act       = new DsfWebGetActivity();
            var webget    = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);
            var inputview = new ManageWebServiceInputViewModel(webget, mod);

            inputview.Model = new WebServiceDefinition();

            //------------Execute Test---------------------------
            var clone = inputview.CloneRegion();

            //------------Assert Results-------------------------
            Assert.AreEqual(inputview, clone);
        }
        public void Webget_Ctor_EmptyModelItem()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();
            var act = new WebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            //------------Execute Test---------------------------
            Assert.IsTrue(webget.SourceRegion.IsEnabled);
            Assert.IsFalse(webget.OutputsRegion.IsEnabled);
            Assert.IsFalse(webget.InputArea.IsEnabled);
            Assert.IsTrue(webget.ErrorRegion.IsEnabled);

            //------------Assert Results-------------------------
        }
Example #14
0
        public void ManageWebServiceInputViewModel_TestActionSetSourceAndTestClickPaste()
        {
            //------------Setup for test--------------------------
            var mod = new MyWebModel();

            var act = new DsfWebGetActivity();

            var webget    = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);
            var inputview = new ManageWebServiceInputViewModel(webget, mod);

            inputview.Model = new WebServiceDefinition();
            //------------Execute Test---------------------------
            inputview.ExecutePaste();

            //------------Assert Results-------------------------
            Assert.IsTrue(inputview.PasteResponseVisible);
        }
        public void ManageWebServiceInputViewModel_PropertyChangedHandler()
        {
            //------------Setup for test--------------------------
            var mod = new MyWebModel();

            var act       = new WebGetActivity();
            var called    = false;
            var webget    = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);
            var inputview = new ManageWebServiceInputViewModel(webget, mod);

            inputview.PropertyChanged += (sender, args) => called = true;
            inputview.Model            = new WebServiceDefinition();
            //------------Execute Test---------------------------
            inputview.ExecuteTest();

            //------------Assert Results-------------------------
            Assert.IsTrue(called);
        }
        public void GetHeaderRegion_GivenIsNew_ShouldReturnInputArea()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var mod = new MyWebModel();
            var act = new WebGetActivity();

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            //------------Execute Test---------------------------
            Assert.IsTrue(webget.SourceRegion.IsEnabled);
            Assert.IsFalse(webget.OutputsRegion.IsEnabled);
            Assert.IsFalse(webget.InputArea.IsEnabled);
            Assert.IsTrue(webget.ErrorRegion.IsEnabled);

            //------------Assert Results-------------------------
            Assert.AreSame(webget.InputArea, webget.GetHeaderRegion());
        }
Example #17
0
        public void ManageWebServiceInputViewModelOkAction_Exception()
        {
            //------------Setup for test--------------------------
            var mod = new MyWebModel();

            mod.HasRecError = true;

            var act       = new DsfWebGetActivity();
            var webget    = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);
            var inputview = new ManageWebServiceInputViewModel(webget, mod);

            webget.OutputsRegion.Outputs = null;

            //------------Execute Test---------------------------
            inputview.ExecuteOk();

            //------------Assert Results-------------------------
            Assert.IsTrue(inputview.Errors.Count == 1);
        }
        public void WebGetDesignerViewModel_UpdateHelp_ShouldCallToHelpViewMode()
        {
            //------------Setup for test--------------------------
            var mockMainViewModel = new Mock <IShellViewModel>();
            var mockHelpViewModel = new Mock <IHelpWindowViewModel>();

            mockHelpViewModel.Setup(model => model.UpdateHelpText(It.IsAny <string>())).Verifiable();
            mockMainViewModel.Setup(model => model.HelpViewModel).Returns(mockHelpViewModel.Object);
            CustomContainer.Register(mockMainViewModel.Object);

            var mod       = new MyWebModel();
            var act       = new WebGetActivity();
            var viewModel = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            //------------Execute Test---------------------------
            viewModel.UpdateHelpDescriptor("help");
            //------------Assert Results-------------------------
            mockHelpViewModel.Verify(model => model.UpdateHelpText(It.IsAny <string>()), Times.Once());
        }
        public void ManageWebServiceInputViewModel_TestAction_Exception()
        {
            //------------Setup for test--------------------------
            var mod = new MyWebModel
            {
                HasRecError = true
            };

            var act       = new WebGetActivity();
            var webget    = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);
            var inputview = new ManageWebServiceInputViewModel(webget, mod)
            {
                Model = null
            };

            //------------Execute Test---------------------------
            inputview.ExecuteTest();

            //------------Assert Results-------------------------
            Assert.IsTrue(inputview.Errors.Count == 1);
        }
        public void ManageWebServiceInputViewModel_TestAction()
        {
            var called   = false;
            var calledOk = false;

            var mod = new MyWebModel();
            var act = new WebGetActivity()
            {
                SourceId = mod.Sources[0].Id,
                Outputs  = new List <IServiceOutputMapping> {
                    new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("d", "e", "f")
                },
                Headers = new List <INameValue> {
                    new NameValue("a", "x")
                },
                QueryString = "Bob the builder",
                ServiceName = "dsfBob"
            };

            var webget = new WebServiceGetViewModel(ModelItemUtils.CreateModelItem(act), mod);

            var vm = new ManageWebServiceInputViewModel(webget, mod)
            {
                TestAction = () => { called = true; },
                OkAction   = () =>
                {
                    calledOk = true;
                }
            };

            vm.TestAction();
            vm.OkAction();

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

            Assert.IsTrue(called);
            Assert.IsTrue(calledOk);
        }
Example #21
0
        public void GivenIDragWebGetRequestConnectorToolOntoTheDesignSurface()
        {
            var activity  = new WebGetActivity();
            var modelItem = ModelItemUtils.CreateModelItem(activity);
            var mockServiceInputViewModel = new Mock <IManageWebServiceInputViewModel>();
            var mockServiceModel          = new Mock <IWebServiceModel>();
            var mockEnvironmentRepo       = new Mock <IServerRepository>();
            var mockEnvironmentModel      = new Mock <IServer>();

            mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true);
            mockEnvironmentModel.Setup(model => model.IsLocalHost).Returns(true);
            mockEnvironmentModel.Setup(model => model.EnvironmentID).Returns(Guid.Empty);
            mockEnvironmentModel.Setup(model => model.IsLocalHostCheck()).Returns(false);
            mockEnvironmentRepo.Setup(repository => repository.ActiveServer).Returns(mockEnvironmentModel.Object);
            mockEnvironmentRepo.Setup(repository => repository.FindSingle(It.IsAny <Expression <Func <IServer, bool> > >())).Returns(mockEnvironmentModel.Object);

            _otherwebsource = new WebServiceSourceDefinition
            {
                Name     = "OtherWebSource",
                HostName = @"http://www.google.com",
                Id       = Guid.NewGuid()
            };


            _weblocalhostsource = new WebServiceSourceDefinition
            {
                Name     = "LocalhostSource",
                HostName = @"http://TFSBLD.premier.local:9810/api/products/Get",
                Id       = Guid.NewGuid()
            };

            var webService = new WebService
            {
                RequestResponse = "[{\"Category\":\"Electronic\",\"Id\":\"1\",\"Name\":\"Television\",\"Price\":\"82000\"},{\"Category\":\"Electronic\",\"Id\":\"2\",\"Name\":\"Refrigerator\",\"Price\":\"23000\"},{\"Category\":\"Electronic\",\"Id\":\"3\",\"Name\":\"Mobiles\",\"Price\":\"20000\"},{\"Category\":\"Electronic\",\"Id\":\"4\",\"Name\":\"Laptops\",\"Price\":\"45000\"},{\"Category\":\"Electronic\",\"Id\":\"5\",\"Name\":\"iPads\",\"Price\":\"67000\"},{\"Category\":\"Gift Items\",\"Id\":\"6\",\"Name\":\"Toys\",\"Price\":\"15000\"}]",
                Recordsets      = new RecordsetList
                {
                    new Dev2.Runtime.ServiceModel.Data.Recordset
                    {
                        Name   = "UnnamedArrayData",
                        Fields = new List <RecordsetField>
                        {
                            new RecordsetField
                            {
                                Alias          = "Id",
                                Name           = "Id",
                                RecordsetAlias = ""
                            },
                            new RecordsetField
                            {
                                Alias          = "Name",
                                Name           = "Name",
                                RecordsetAlias = ""
                            },
                            new RecordsetField
                            {
                                Alias          = "Category",
                                Name           = "Category",
                                RecordsetAlias = ""
                            },
                            new RecordsetField
                            {
                                Alias          = "Price",
                                Name           = "Price",
                                RecordsetAlias = ""
                            }
                        }
                    }
                }
            };
            var serializer = new Dev2JsonSerializer();
            var testResult = serializer.Serialize(webService);

            var sources = new ObservableCollection <IWebServiceSource> {
                _weblocalhostsource, _otherwebsource
            };

            mockServiceModel.Setup(model => model.RetrieveSources()).Returns(sources);
            mockServiceModel.Setup(model => model.Sources).Returns(sources);
            mockServiceModel.Setup(model => model.EditSource(It.IsAny <IWebServiceSource>())).Verifiable();
            mockServiceInputViewModel.SetupAllProperties();
            mockServiceModel.Setup(model => model.TestService(It.IsAny <IWebService>())).Returns(testResult);
            var viewModel = new WebServiceGetViewModel(modelItem, mockServiceModel.Object);

            _scenarioContext.Add("viewModel", viewModel);
            _scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel);
            _scenarioContext.Add("mockServiceModel", mockServiceModel);
        }