public void PropagateNotToLeaves() { var query = m_QE.Parse("-(a and b or c)"); QueryEngineTests.ValidateNoErrors(query); var graph = query.graph; Assert.DoesNotThrow(() => { graph.Optimize(true, false); }); Assert.IsFalse(graph.root.leaf); Assert.IsInstanceOf(typeof(AndNode), graph.root); Assert.AreEqual(2, graph.root.children.Count); Assert.IsInstanceOf(typeof(OrNode), graph.root.children[0]); Assert.IsInstanceOf(typeof(NotNode), graph.root.children[1]); var orNode = graph.root.children[0]; var notNode = graph.root.children[1]; Assert.IsFalse(orNode.leaf); Assert.AreEqual(2, orNode.children.Count); Assert.IsInstanceOf(typeof(NotNode), orNode.children[0]); Assert.IsInstanceOf(typeof(SearchNode), orNode.children[0].children[0]); Assert.IsInstanceOf(typeof(NotNode), orNode.children[1]); Assert.IsInstanceOf(typeof(SearchNode), orNode.children[1].children[0]); Assert.IsInstanceOf(typeof(SearchNode), notNode.children[0]); }
public void ReduceNotDepth() { var query = m_QE.Parse("---a"); QueryEngineTests.ValidateNoErrors(query); var graph = query.graph; Assert.DoesNotThrow(() => { graph.Optimize(false, false); }); Assert.IsFalse(graph.root.leaf); Assert.IsInstanceOf(typeof(NotNode), graph.root); Assert.IsInstanceOf(typeof(SearchNode), graph.root.children[0]); query = m_QE.Parse("----a"); QueryEngineTests.ValidateNoErrors(query); graph = query.graph; Assert.DoesNotThrow(() => { graph.Optimize(false, false); }); Assert.IsTrue(graph.root.leaf); Assert.IsInstanceOf(typeof(SearchNode), graph.root); }
public void Init() { m_QE = new QueryEngine(); Assert.DoesNotThrow(() => { QueryEngineTests.SetupQueryEngine(m_QE); }); }
public void OptimizeSwapNot() { var query = m_QE.Parse("-i>20 n=Bob"); QueryEngineTests.ValidateNoErrors(query); var graph = query.graph; Assert.DoesNotThrow(() => { graph.Optimize(false, true); }); Assert.IsFalse(graph.root.leaf); Assert.IsInstanceOf(typeof(AndNode), graph.root); Assert.IsInstanceOf(typeof(FilterNode), graph.root.children[0]); Assert.IsInstanceOf(typeof(NotNode), graph.root.children[1]); query = m_QE.Parse("n=Bob -i>20"); QueryEngineTests.ValidateNoErrors(query); graph = query.graph; Assert.DoesNotThrow(() => { graph.Optimize(false, true); }); Assert.IsFalse(graph.root.leaf); Assert.IsInstanceOf(typeof(AndNode), graph.root); Assert.IsInstanceOf(typeof(FilterNode), graph.root.children[0]); Assert.IsInstanceOf(typeof(NotNode), graph.root.children[1]); query = m_QE.Parse("-(-i>20 n=Bob) or i>42"); QueryEngineTests.ValidateNoErrors(query); graph = query.graph; Assert.DoesNotThrow(() => { graph.Optimize(false, true); }); Assert.IsFalse(graph.root.leaf); Assert.IsInstanceOf(typeof(OrNode), graph.root); Assert.IsInstanceOf(typeof(FilterNode), graph.root.children[0]); Assert.IsInstanceOf(typeof(NotNode), graph.root.children[1]); var notNode = graph.root.children[1]; Assert.IsFalse(notNode.leaf); Assert.IsInstanceOf(typeof(AndNode), notNode.children[0]); var andNode = notNode.children[0]; Assert.IsFalse(andNode.leaf); Assert.IsInstanceOf(typeof(FilterNode), andNode.children[0]); Assert.IsInstanceOf(typeof(NotNode), andNode.children[1]); }
public void BasicSearch([ValueSource(nameof(k_SampleSize))] int sampleSize) { var data = GenerateTestObjects(sampleSize); List <TestObject> filteredData = null; using (new DebugTimer("BasicSearch")) { var query = m_QE.Parse("a=true s=ValueB Dat"); QueryEngineTests.ValidateNoErrors(query); filteredData = query.Apply(data).Cast <TestObject>().ToList(); } Assert.IsNotEmpty(filteredData); }