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() }; using (var _dependencyOps = new Depends(Depends.ContainerType.HTTPVerbsApi)) { _weblocalhostsource = new WebServiceSourceDefinition { Name = "LocalhostSource", HostName = $"http://{_dependencyOps.Container.IP}:{_dependencyOps.Container.Port}/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 WebGetActivityViewModel(modelItem, mockServiceModel.Object); _scenarioContext.Add("viewModel", viewModel); _scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel); _scenarioContext.Add("mockServiceModel", mockServiceModel); }
public void ManageWebServiceInputViewModel_LoadConditionExpressionOptions() { var myWebModel = new MyWebModel(); var webGetActivity = new WebGetActivity() { SourceId = myWebModel.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 webGetActivityViewModel = new WebGetActivityViewModel(ModelItemUtils.CreateModelItem(webGetActivity), myWebModel); //------------Assert Results------------------------- var inputViewModel = new ManageWebServiceInputViewModel(webGetActivityViewModel, myWebModel) { IsFormDataChecked = true }; Assert.IsTrue(inputViewModel.IsFormDataChecked); Assert.IsNotNull(inputViewModel.ConditionExpressionOptions); Assert.AreEqual(1, inputViewModel.ConditionExpressionOptions.Options.Count); var formDataConditionMatch = new FormDataConditionText { Value = enFormDataTableType.Text.ToString() }; var formDataOptionConditionExpression = new FormDataOptionConditionExpression { Key = "a", Cond = formDataConditionMatch, Value = "b" }; var options = new List <IOption> { formDataOptionConditionExpression }; inputViewModel.LoadConditionExpressionOptions(options); Assert.IsNotNull(inputViewModel.ConditionExpressionOptions); Assert.AreEqual(2, inputViewModel.ConditionExpressionOptions.Options.Count); var expressionWithInput = inputViewModel.ConditionExpressionOptions.Options[0] as FormDataOptionConditionExpression; Assert.IsNotNull(expressionWithInput); Assert.AreEqual("a", expressionWithInput.Key); Assert.AreEqual(enFormDataTableType.Text, expressionWithInput.Cond.TableType); Assert.AreEqual("b", expressionWithInput.Value); var emptyExpression = inputViewModel.ConditionExpressionOptions.Options[1] as FormDataOptionConditionExpression; Assert.IsNotNull(emptyExpression); Assert.IsNull(emptyExpression.Key); Assert.IsNull(emptyExpression.Cond); Assert.IsNull(emptyExpression.Value); expressionWithInput.DeleteCommand.Execute(expressionWithInput); Assert.AreEqual(1, inputViewModel.ConditionExpressionOptions.Options.Count); }