Lucene.Net.Search.TestSparseFacetedSearch.Test3 C# (CSharp) Method

Test3() private method

private Test3 ( ) : void
return void
        public void Test3()
        {
            Query query = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "text", new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)).Parse("block*");

            var sfs = new SparseFacetedSearcher(_Reader, "lang", "source", "category");
            var hits = sfs.Search(query);

            Assert.AreEqual(6, hits.Facets.Count());
            int nohit = 0;

            foreach (var hpg in hits.Facets)
            {
                //Test for [System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary.]
                var x = hits[hpg.Name];
                var y = hits[hpg.Name.ToString()];

                if (hpg.Name[0] == "us" && hpg.Name[1] == "CCN" && hpg.Name[2] == "politics")
                {
                    Assert.AreEqual(1, hpg.Count);
                }
                else
                    if (hpg.Name[0] == "en" && hpg.Name[1] == "BCC" && hpg.Name[2] == "tech")
                    {
                        Assert.AreEqual(1, hpg.Count);
                    }
                    else
                        if (hpg.Name[0] == "us" && hpg.Name[1] == "CCN" && hpg.Name[2] == "sport")
                        {
                            Assert.AreEqual(1, hpg.Count);
                        }
                        else
                            if (hpg.Name[0] == "en" && hpg.Name[1] == "CCN" && hpg.Name[2] == "tech")
                            {
                                Assert.AreEqual(1, hpg.Count);
                            }
                            else
                            {
                                nohit++;
                                Assert.AreEqual(0, hpg.Count);
                            }
            }
            Assert.AreEqual(2, nohit);
            Assert.AreEqual(4, hits.TotalHitCount);

            foreach (var hpg in hits.Facets)
            {
                foreach (Document doc in hpg.Documents)
                {
                    string text = doc.GetField("text").StringValue();
                    Assert.IsTrue(text.Contains("block"));
                }
            }
        }