Пример #1
0
        public void WhereTest_DecisionOnTree()
        {
            string dataJson = @"{
                ""Source"": ""WEC-CDOC"",
                ""OccurenceUtc"": ""2018-09-11T22:22:13.0000000Z"",
                ""Origin"": {},
                ""ArisId"": ""f57a0c50-9326-409d-85a4-f15aca0e7392"",
                ""Name"": ""GME Smartcard Service Accounts - SIM-00011"",
                ""Data"": {
                  ""detectionDictionaryData_RxKqlDetectionItemEntityId"": ""1414"",
                  ""Rows"": [
                            {""IcmTeam"" : ""a""},
                            {""IcmTeam"" : ""b""},
                          ],
                }
              }";

            var expando = JsonConvert.DeserializeObject <ExpandoObject>(dataJson);

            try
            {
                string whereExpression = @"Data.Rows[0].IcmTeam == ""a""";
                var    whereOperator   = new WhereOperator(whereExpression);
                var    result          = whereOperator.Evaluate(expando);
                Assert.IsTrue(result);

                whereExpression = @"Data.Rows[1].IcmTeam == ""b""";
                whereOperator   = new WhereOperator(whereExpression);
                result          = whereOperator.Evaluate(expando);
                Assert.IsTrue(result);

                whereExpression = @"Data.Rows[0].IcmTeam != ""b""";
                whereOperator   = new WhereOperator(whereExpression);
                result          = whereOperator.Evaluate(expando);
                Assert.IsTrue(result);

                whereExpression = @"Data.Rows[1].IcmTeam != ""b""";
                whereOperator   = new WhereOperator(whereExpression);
                result          = whereOperator.Evaluate(expando);
                Assert.IsFalse(result);
            }
            catch (Exception exception)
            {
                Console.WriteLine($"Extend Failed: {exception}");
            }
        }