示例#1
0
        public void Evaluate_WithRegexInExpression_ReturnsFalse()
        {
            var dynamicFilter = new DynamicStockFilter("Regex.IsMatch(Stock.Identifier, \"(?i)^[ABC]\")");
            var stock         = new SpreadBet.Domain.Stock
            {
                Identifier = "XYZ.L"
            };

            var result = dynamicFilter.Evaluate(stock);

            Assert.IsFalse(result);
        }
示例#2
0
        public void Evaluate_ExpressionDoesNotContainStockReference_ResolvesStockProperty()
        {
            var dynamicFilter = new DynamicStockFilter("Identifier == \"ABC.L\"");

            var stock = new SpreadBet.Domain.Stock
            {
                Identifier = "ABC.L"
            };

            var result = dynamicFilter.Evaluate(stock);

            Assert.IsTrue(result);
        }
示例#3
0
        public void Evaluate_WithValidExpression_ReturnsTrue()
        {
            var dynamicFilter = new DynamicStockFilter("Stock.Identifier.ToUpper().SubString(0,1) = \"A\"");

            var stock = new SpreadBet.Domain.Stock
            {
                Identifier = "ABC.L"
            };

            var result = dynamicFilter.Evaluate(stock);

            Assert.IsTrue(result);
        }