/// <summary>
        /// Executes the construction step the specified node to ensure it is "correct" in the context of the rule doing the valdiation.
        /// </summary>
        /// <param name="context">The validation context encapsulating a <see cref="SyntaxNode" /> that needs to be validated.</param>
        /// <returns><c>true</c> if the node is valid, <c>false</c> otherwise.</returns>
        public override bool Execute(DocumentConstructionContext context)
        {
            var node          = (VariableNode)context.ActiveNode;
            var queryVariable = new QueryVariable(node);

            context.AddDocumentPart(queryVariable);

            return(true);
        }
        public void MockItemWithVariables()
        {
            var variable      = new QueryVariable("Name", "Name1", "Name2", "Name3");
            var nameAttribute = new MockAttributeDefinition("Name");

            var query = new Query(new MockAssetType());

            query.Variables.Add(variable);
            var filter = new FilterTerm(nameAttribute);

            filter.Operate(FilterTerm.Operator.Equal, variable);
            query.Filter = filter;
            query.Selection.Add(new MockAttributeDefinition("Reference"));
            var builder = new QueryURLBuilder(query);

            Assert.AreEqual("Data/Mock?sel=Mock.Reference&where=Mock.Name=$Name&with=$Name=Name1,Name2,Name3", builder.ToString());
        }
        public void DatePrecisionInVariable()
        {
            var date = new DateTime(2012, 6, 21, 15, 17, 53, 504);
            var changeDateAttribute = new MockAttributeDefinition("ChangeDate");

            var query    = new Query(new MockAssetType());
            var variable = new QueryVariable("requestedDate", date);

            query.Selection.Add(new MockAttributeDefinition("Name"));
            query.Variables.Add(variable);
            var filter = new FilterTerm(changeDateAttribute);

            filter.Operate(FilterTerm.Operator.Equal, variable);
            var builder = new QueryURLBuilder(query);

            query.Filter = filter;

            var queryString = builder.ToString();

            Assert.AreEqual("Data/Mock?sel=Mock.Name&where=Mock.ChangeDate=$requestedDate&with=$requestedDate=2012-06-21T15%3a17%3a53.504", queryString);
        }
        public void QueryTrackedEpicsForMultipleProjectsUsingVariables()
        {
            var metaConnector = new V1APIConnector(VersionOneUrl + "meta.v1/", "admin", "admin");
            var metaModel     = new MetaModel(metaConnector);

            var scopeVariable = new QueryVariable("Scope", "Scope:2176");

            var epicType = metaModel.GetAssetType("Epic");

            var query = new Query(epicType);

            var notClosedEpicAttribute = epicType.GetAttributeDefinition("AssetState");

            var notClosedEpicTerm = new FilterTerm(notClosedEpicAttribute);

            notClosedEpicTerm.NotEqual("Closed");

            var scopeAttribute = epicType.GetAttributeDefinition("Scope");
            var scopeTerm      = new FilterTerm(scopeAttribute);

            scopeTerm.Operate(FilterTerm.Operator.Equal, scopeVariable);

            var superAndUpAttribute = epicType.GetAttributeDefinition("SuperAndUp").Filter(scopeTerm);
            var superAndUpTerm      = new FilterTerm(superAndUpAttribute);

            superAndUpTerm.NotExists();

            var filter = new AndFilterTerm(notClosedEpicTerm, scopeTerm, superAndUpTerm);

            query.Filter = filter;
            query.Variables.Add(scopeVariable);
            var builder = new QueryURLBuilder(query);
            var result  = builder.ToString();

            Assert.AreEqual("Data/Epic?sel=&where=(Epic.AssetState!='Closed';Epic.Scope=$Scope;-Epic.SuperAndUp[Scope=$Scope])&with=$Scope=Scope%3A2176", result);
        }
Exemplo n.º 5
0
 private QueryVariable CreateVariable(XmlNode VarNode)
 {
     QueryVariable tmpVar = new QueryVariable();
     tmpVar.Default = VarNode.Attributes[0].Value;
     tmpVar.Question = VarNode.InnerText;
     return tmpVar;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Attaches a variable found within an operation to this input value to carry for future operations.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public void AssignVariableReference(QueryVariable variable)
 {
     this.Variable = Validation.ThrowIfNullOrReturn(variable, nameof(variable));
 }
		public void QueryTrackedEpicsForMultipleProjectsUsingVariables() {
			var metaConnector = new V1APIConnector(VersionOneUrl + "meta.v1/", "admin", "admin");
			var metaModel = new MetaModel(metaConnector);

			var scopeVariable = new QueryVariable("Scope", "Scope:2176");

			var epicType = metaModel.GetAssetType("Epic");

			var query = new Query(epicType);

			var notClosedEpicAttribute = epicType.GetAttributeDefinition("AssetState");

			var notClosedEpicTerm = new FilterTerm(notClosedEpicAttribute);
			notClosedEpicTerm.NotEqual("Closed");

			var scopeAttribute = epicType.GetAttributeDefinition("Scope");
			var scopeTerm = new FilterTerm(scopeAttribute);
			scopeTerm.Operate(FilterTerm.Operator.Equal, scopeVariable);

			var superAndUpAttribute = epicType.GetAttributeDefinition("SuperAndUp").Filter(scopeTerm);
			var superAndUpTerm = new FilterTerm(superAndUpAttribute);
			superAndUpTerm.NotExists();
			
			var filter = new AndFilterTerm(notClosedEpicTerm, scopeTerm, superAndUpTerm);
			query.Filter = filter;
			query.Variables.Add(scopeVariable);
			var builder = new QueryURLBuilder(query);
			var result = builder.ToString();
			Assert.AreEqual("Data/Epic?sel=&where=(Epic.AssetState!='Closed';Epic.Scope=$Scope;-Epic.SuperAndUp[Scope=$Scope])&with=$Scope=Scope%3A2176", result);
		}
		public void DatePrecisionInVariable() {
			var date = new DateTime(2012, 6, 21, 15, 17, 53, 504);
			var changeDateAttribute = new MockAttributeDefinition("ChangeDate");

			var query = new Query(new MockAssetType());
			var variable = new QueryVariable("requestedDate", date);
			query.Selection.Add(new MockAttributeDefinition("Name"));
			query.Variables.Add(variable);
			var filter = new FilterTerm(changeDateAttribute);
			filter.Operate(FilterTerm.Operator.Equal, variable);
			var builder = new QueryURLBuilder(query);
			query.Filter = filter;

			var queryString = builder.ToString();
			Assert.AreEqual("Data/Mock?sel=Mock.Name&where=Mock.ChangeDate=$requestedDate&with=$requestedDate=2012-06-21T15%3a17%3a53.504", queryString);
		}
		public void MockItemWithVariables() {
			var variable = new QueryVariable("Name", "Name1", "Name2", "Name3");
			var nameAttribute = new MockAttributeDefinition("Name");

			var query = new Query(new MockAssetType());
			query.Variables.Add(variable);
			var filter = new FilterTerm(nameAttribute);
			filter.Operate(FilterTerm.Operator.Equal, variable);
			query.Filter = filter;
			query.Selection.Add(new MockAttributeDefinition("Reference"));
			var builder = new QueryURLBuilder(query);
			Assert.AreEqual("Data/Mock?sel=Mock.Reference&where=Mock.Name=$Name&with=$Name=Name1,Name2,Name3", builder.ToString());
		}