Ejemplo n.º 1
0
 protected void executeQueries(SpatialMatchConcern concern, params String[] testQueryFile)
 {
     Console.WriteLine("testing queries for strategy " + strategy + ". Executer: " + GetType().Name);
     foreach (String path in testQueryFile)
     {
         IEnumerator<SpatialTestQuery> testQueryIterator = getTestQueries(path, ctx);
         runTestQueries(testQueryIterator, concern);
     }
 }
Ejemplo n.º 2
0
 protected void executeQueries(SpatialMatchConcern concern, params String[] testQueryFile)
 {
     Console.WriteLine("testing queries for strategy " + strategy + ". Executer: " + GetType().Name);
     foreach (String path in testQueryFile)
     {
         IEnumerator <SpatialTestQuery> testQueryIterator = getTestQueries(path, ctx);
         runTestQueries(testQueryIterator, concern);
     }
 }
Ejemplo n.º 3
0
        public void runTestQueries(
            IEnumerator<SpatialTestQuery> queries,
            SpatialMatchConcern concern)
        {
            while (queries.MoveNext())
            {
                SpatialTestQuery q = queries.Current;

                String msg = q.line; //"Query: " + q.args.toString(ctx);
                SearchResults got = executeQuery(strategy.MakeQuery(q.args), 100);
                if (storeShape && got.numFound > 0)
                {
                    //check stored value is there & parses
                    assertNotNull(ctx.ReadShape(got.results[0].document.Get(strategy.GetFieldName())));
                }
                if (concern.orderIsImportant)
                {
                    var ids = q.ids.GetEnumerator();
                    foreach (var r in got.results)
                    {
                        String id = r.document.Get("id");
                        if (!ids.MoveNext())
                            Assert.Fail(msg + " :: Did not get enough results.  Expected " + q.ids + ", got: " +
                                        got.toDebugString());
                        Assert.AreEqual(ids.Current, id, "out of order: " + msg);
                    }
                    if (ids.MoveNext())
                    {
                        Assert.Fail(msg + " :: expect more results then we got: " + ids.Current);
                    }
                }
                else
                {
                    // We are looking at how the results overlap
                    if (concern.resultsAreSuperset)
                    {
                        var found = new HashSet<String>();
                        foreach (var r in got.results)
                        {
                            found.Add(r.document.Get("id"));
                        }
                        foreach (String s in q.ids)
                        {
                            if (!found.Contains(s))
                            {
                                Assert.Fail("Results are mising id: " + s + " :: " + found);
                            }
                        }
                    }
                    else
                    {
                        var found = new List<String>();
                        foreach (SearchResult r in got.results)
                        {
                            found.Add(r.document.Get("id"));
                        }

                        // sort both so that the order is not important
                        q.ids.Sort();
                        found.Sort();
                        Assert.AreEqual(q.ids.Count, found.Count);
                        for (var i = 0; i < found.Count; i++)
                        {
                            Assert.AreEqual(q.ids[i], found[i], msg);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void runTestQueries(
            IEnumerator <SpatialTestQuery> queries,
            SpatialMatchConcern concern)
        {
            while (queries.MoveNext())
            {
                SpatialTestQuery q = queries.Current;

                String        msg = q.line; //"Query: " + q.args.toString(ctx);
                SearchResults got = executeQuery(strategy.MakeQuery(q.args), 100);
                if (storeShape && got.numFound > 0)
                {
                    //check stored value is there & parses
                    assertNotNull(ctx.ReadShape(got.results[0].document.Get(strategy.GetFieldName())));
                }
                if (concern.orderIsImportant)
                {
                    var ids = q.ids.GetEnumerator();
                    foreach (var r in got.results)
                    {
                        String id = r.document.Get("id");
                        if (!ids.MoveNext())
                        {
                            Assert.Fail(msg + " :: Did not get enough results.  Expected " + q.ids + ", got: " +
                                        got.toDebugString());
                        }
                        Assert.AreEqual(ids.Current, id, "out of order: " + msg);
                    }
                    if (ids.MoveNext())
                    {
                        Assert.Fail(msg + " :: expect more results then we got: " + ids.Current);
                    }
                }
                else
                {
                    // We are looking at how the results overlap
                    if (concern.resultsAreSuperset)
                    {
                        var found = new HashSet <String>();
                        foreach (var r in got.results)
                        {
                            found.Add(r.document.Get("id"));
                        }
                        foreach (String s in q.ids)
                        {
                            if (!found.Contains(s))
                            {
                                Assert.Fail("Results are mising id: " + s + " :: " + found);
                            }
                        }
                    }
                    else
                    {
                        var found = new List <String>();
                        foreach (SearchResult r in got.results)
                        {
                            found.Add(r.document.Get("id"));
                        }

                        // sort both so that the order is not important
                        q.ids.Sort();
                        found.Sort();
                        Assert.AreEqual(q.ids.Count, found.Count);
                        for (var i = 0; i < found.Count; i++)
                        {
                            Assert.AreEqual(q.ids[i], found[i], msg);
                        }
                    }
                }
            }
        }