コード例 #1
0
        public void ShouldReturn1WhenFirstParamIsSomethingAndSecondParamIsNull()
        {
            object o1     = 1;
            object o2     = null;
            var    result = _matcher.IsMatch(o1, o2);

            Assert.AreEqual(1, result);
        }
コード例 #2
0
ファイル: LookupFunction.cs プロジェクト: nxoxn/EPPlus
        protected CompileResult Lookup(LookupNavigator navigator, LookupArguments lookupArgs, ValueMatcher valueMatcher)
        {
            object lastValue       = null;
            object lastLookupValue = null;
            int?   lastMatchResult = null;

            if (lookupArgs.SearchedValue == null)
            {
                return(new CompileResult(eErrorType.NA));
            }
            do
            {
                var matchResult = valueMatcher.IsMatch(lookupArgs.SearchedValue, navigator.CurrentValue);
                if (matchResult != 0)
                {
                    if (lastValue != null && navigator.CurrentValue == null)
                    {
                        break;
                    }

                    if (!lookupArgs.RangeLookup)
                    {
                        continue;
                    }
                    if (lastValue == null && matchResult < 0)
                    {
                        return(new CompileResult(eErrorType.NA));
                    }
                    if (lastValue != null && matchResult < 0 && lastMatchResult > 0)
                    {
                        return(new CompileResultFactory().Create(lastLookupValue));
                    }
                    lastMatchResult = matchResult;
                    lastValue       = navigator.CurrentValue;
                    lastLookupValue = navigator.GetLookupValue();
                }
                else
                {
                    return(new CompileResultFactory().Create(navigator.GetLookupValue()));
                }
            }while (navigator.MoveNext());

            return(lookupArgs.RangeLookup ? new CompileResultFactory().Create(lastLookupValue) : new CompileResult(eErrorType.NA));
        }
コード例 #3
0
 protected int IsMatch(object o1, object o2)
 {
     return(_valueMatcher.IsMatch(o1, o2));
 }
コード例 #4
0
 public void ShouldReturnMinus1WhenFirstParamIsSomethingAndSecondParamIsNull()
 {
     object searchedValue = 1;
     object o2 = null;
     var result = _matcher.IsMatch(searchedValue, o2);
     Assert.AreEqual(-1, result);
 }
コード例 #5
0
 protected int IsMatch(object searchedValue, object candidate)
 {
     return(_valueMatcher.IsMatch(searchedValue, candidate));
 }