示例#1
0
        public void GetResults_MultiTokenIndex_Success()
        {
            var mockedInvertedIndex = new Mock <IInvertedIndex>();

            mockedInvertedIndex.Setup(index => index.GetDocumentsOfToken(new Token("first")))
            .Returns(
                new HashSet <Document>
            {
                new Document("doc1.txt", "simple/path"),
                new Document("doc2.txt", "simple/path"),
                new Document("doc3.txt", "simple/path"),
            }
                );
            mockedInvertedIndex.Setup(index => index.GetDocumentsOfToken(new Token("second")))
            .Returns(
                new HashSet <Document>
            {
                new Document("doc2.txt", "simple/path"),
                new Document("doc3.txt", "simple/path"),
            }
                );
            var expected = new HashSet <Document>
            {
                new Document("doc2.txt", "simple/path"),
                new Document("doc3.txt", "simple/path")
            };

            var objectUnderTest = new AndTerms("first second -third");
            var actual          = objectUnderTest.GetResults(mockedInvertedIndex.Object);

            Assert.Equal(expected, actual);
        }
示例#2
0
        public void Constructor_NoAnds_Success()
        {
            var expected = new List <Token>();
            var actual   = new AndTerms("-first +second2 -3rd").Tokens;

            Assert.Equal(expected, actual);
        }
示例#3
0
        public void Constructor_SomeAnds_Success()
        {
            var expected = new List <Token>
            {
                new Token("first"),
                new Token("4th"),
                new Token("5th"),
            };
            var actual = new AndTerms("first +second2 -3rd 4th 5th").Tokens;

            Assert.Equal(expected, actual);
        }
示例#4
0
        public void Constructor_OnlyAnds_Success()
        {
            var expected = new List <Token>
            {
                new Token("first"),
                new Token("second2"),
                new Token("3rd")
            };
            var actual = new AndTerms("first second2 3rd").Tokens;

            Assert.Equal(expected, actual);
        }
示例#5
0
 private void CollectTerms(string expression)
 {
     Ands = new AndTerms(expression);
     Ors  = new OrTerms(expression);
     Excs = new ExcTerms(expression);
 }