Exemplo n.º 1
0
        public void HandlesNotStartsWith()
        {
            // Act
            var result = new FilterClause("startsWith(input, 'abcd') eq false");

            // Assert
            Assert.AreEqual(result.FieldName, "input");
            Assert.IsTrue(result.Predicate("234567"));
            Assert.IsFalse(result.Predicate("abcd"));
        }
Exemplo n.º 2
0
        public void HandlesNotContains()
        {
            // Act
            var result = new FilterClause("contains(input,'abcd') eq false");

            // Assert
            Assert.AreEqual(result.FieldName, "input");
            Assert.IsTrue(result.Predicate("12345"));
            Assert.IsFalse(result.Predicate("123abcd45"));
        }
Exemplo n.º 3
0
        public void HandlesStartsWith()
        {
            // Act
            var result = new FilterClause("startsWith(input, 'abcd')");

            // Assert
            Assert.AreEqual(result.FieldName, "input");
            Assert.IsTrue(result.Predicate("abcdef"));
            Assert.IsFalse(result.Predicate("fedcba"));
        }
Exemplo n.º 4
0
        public void HandlesNe()
        {
            // Act
            var result = new FilterClause("input ne 'abcd'");

            // Assert
            Assert.AreEqual(result.FieldName, "input");
            Assert.IsTrue(result.Predicate("dcba"));
            Assert.IsFalse(result.Predicate("abcd"));
        }
Exemplo n.º 5
0
        public void HandlesNotIn()
        {
            // Act
            var result = new FilterClause("input in ( 1 , 2  )  eq   false");

            // Assert
            Assert.AreEqual(result.FieldName, "input");
            Assert.IsTrue(result.Predicate(3.ToString()));
            Assert.IsFalse(result.Predicate(1.ToString()));
            Assert.IsFalse(result.Predicate(2.ToString()));
        }
Exemplo n.º 6
0
        public void HandlesInWithoutQuotes()
        {
            // Act
            var result = new FilterClause("input in (1,2.3,45)");

            // Assert
            Assert.AreEqual(result.FieldName, "input");
            Assert.IsTrue(result.Predicate(1.ToString()));
            Assert.IsTrue(result.Predicate(2.3.ToString()));
            Assert.IsTrue(result.Predicate(45.ToString()));
            Assert.IsFalse(result.Predicate("54321"));
        }
Exemplo n.º 7
0
        public void HandlesFullFilter()
        {
            // Arrange
            string filter = $" createdTime  ge '2018-06-16T15:56:07.000Z' and instanceId ne 'abcd'  and    createdTime le   '2021-11-03T01:02:03.000Z' and runtimeStatus in('Failed')";

            // Act
            var result = new FilterClause(filter);

            // Assert
            Assert.AreEqual(result.TimeFrom.Value.ToUniversalTime(), new DateTime(2018, 6, 16, 15, 56, 07, DateTimeKind.Utc));
            Assert.AreEqual(result.TimeTill.Value.ToUniversalTime(), new DateTime(2021, 11, 3, 1, 2, 3, DateTimeKind.Utc));
            Assert.AreEqual(result.FieldName, "instanceId");
            Assert.IsFalse(result.Predicate("abcd"));
            Assert.AreEqual(result.RuntimeStatuses.Length, 1);
            Assert.IsTrue(result.RuntimeStatuses.Contains("Failed"));
        }
Exemplo n.º 8
0
        public void HandlesInWithQuotes()
        {
            // Act
            var result = new FilterClause("input in (')', 'a)bc', ',', '12,3', '(', '')");

            // Assert
            Assert.AreEqual(result.FieldName, "input");
            Assert.IsTrue(result.Predicate(")"));
            Assert.IsTrue(result.Predicate("a)bc"));
            Assert.IsTrue(result.Predicate(","));
            Assert.IsTrue(result.Predicate("12,3"));
            Assert.IsTrue(result.Predicate("("));
            Assert.IsTrue(result.Predicate(""));
            Assert.IsFalse(result.Predicate("54321"));
        }