private void HandleAttributeParameter(QueryParameter parameter) { if (Equals(parameter.Name, "includeAttributes")) { _includeAttributes = parameter.GetValue <bool>(); } else if (Equals(parameter.Name, "attributeNames")) { _attributeNames.AddRange(parameter.Values); } else if (Equals(parameter.Name, "includeChildren")) { _includeChildren = parameter.GetValue <bool>(); } }
private static void ApplyQuantityParameter(QueryParameter parameter, IUnitOfWork unitOfWork) { if (parameter.Values.Length > 1) { throw new EpcisException(ExceptionType.QueryParameterException, "QuantityParameter must have only one value"); } var filterOperator = Enumeration.GetByDisplayName <FilterComparator>(parameter.Name.Substring(0, 2)); unitOfWork.EventManager.WhereEpcQuantityMatches(filterOperator, parameter.GetValue <double>()); }
public void GetValue_Variable_CorrectValue() { var variable = new GlobalVariable(new CSharpScalarResolver <object>("Math.Min(30, 50)")); var resolver = new GlobalVariableScalarResolver <object>("alpha", new Dictionary <string, ITestVariable>() { { "alpha", variable } }); var param = new QueryParameter("param", resolver); Assert.That(param.GetValue(), Is.EqualTo(30)); }
public void GetValue_Variable_GetValueCalledOnce() { var internalResolverMock = new Mock <IScalarResolver>(); internalResolverMock.Setup(x => x.Execute()).Returns(It.IsAny <object>()); var resolver = new GlobalVariableScalarResolver <object>("alpha", new Dictionary <string, ITestVariable>() { { "alpha", new GlobalVariable(internalResolverMock.Object) } }); var param = new QueryParameter("param", resolver); param.GetValue(); internalResolverMock.Verify(x => x.Execute(), Times.Once); }
private void ApplyParameter(QueryParameter parameter) { if (IsSimpleParameter(parameter, out Action <IEventFetcher, QueryParameter> action) || IsRegexParameter(parameter, out action)) { try { action(_eventFetcher, parameter); } catch (Exception ex) { throw new EpcisException(ExceptionType.QueryParameterException, ex.Message); } if (parameter.Name == "maxEventCount") { _maxEventCount = parameter.GetValue <int>(); } } else { throw new NotImplementedException($"Query parameter unexpected or not implemented: '{parameter.Name}'"); } }
public void GetValue_Literal_CorrectValue() { var param = new QueryParameter("param", "Canada"); Assert.That(param.GetValue(), Is.EqualTo("Canada")); }
private static void ApplyTimeParameter(EpcisField field, QueryParameter parameter, IUnitOfWork unitOfWork) { var filterOperator = Enumeration.GetByDisplayName <FilterComparator>(parameter.Name.Substring(0, 2)); unitOfWork.EventManager.WhereSimpleFieldMatches(field, filterOperator, parameter.GetValue <DateTime>()); }