Example #1
0
        public void GetPostingsTest_TermNotExist_ReturnsEmpty()
        {
            TermLiteral     term   = new TermLiteral("zebra");
            IList <Posting> result = term.GetPostings(index, processor);

            result.Should().BeEmpty("because there's no posting for the term 'zebra'");
        }
Example #2
0
        public void GetPostingsTest_TermWithException_ReturnsEmpty()
        {
            TermLiteral     term   = new TermLiteral("");
            IList <Posting> result = term.GetPostings(index, processor);

            result.Should().BeEmpty("because the term literal has empty string");
        }
Example #3
0
        public void ParsingSingleQueryTest_ReturnsTermLiteral()
        {
            //Arrange
            string      query    = "smoothie";
            TermLiteral expected = new TermLiteral(query);
            //Act
            IQueryComponent actual = parser.ParseQuery(query);

            //Assert
            actual.Should().BeOfType(typeof(TermLiteral));
            ((TermLiteral)actual).Term.Should().BeSameAs(expected.Term);
        }
Example #4
0
        public void GetPostingsTest_TermExist_ReturnsPostings()
        {
            //1. Test for exact words
            TermLiteral     term1  = new TermLiteral("mystery");
            IList <Posting> result = term1.GetPostings(index, processor);

            result.Should().HaveCount(3, "because there are 3 documents that contain the term 'mystery'");

            //2. Test for stemmed words
            TermLiteral     term2   = new TermLiteral("snowing");
            TermLiteral     term3   = new TermLiteral("snows");
            IList <Posting> result2 = term2.GetPostings(index, processor);
            IList <Posting> result3 = term2.GetPostings(index, processor);

            result2.Should().HaveSameCount(result3, "because 'snowing' should be processed and include result of 'snows', 'snowing' or 'snow'");
        }