Exemplo n.º 1
0
        public void Search_ShouldReturnCorrectHashSet(HashSet <string> noSignWords, HashSet <string> plusSignWords,
                                                      HashSet <string> minusSignWords, HashSet <string> expected)
        {
            //Arrange
            _hashInvertedIndex.GetDocsContain("hello").Returns(new HashSet <string>()
            {
                "1", "2", "3"
            });
            _hashInvertedIndex.GetDocsContain("dad").Returns(new HashSet <string>()
            {
                "1", "3", "5"
            });
            _hashInvertedIndex.GetDocsContain("bank").Returns(new HashSet <string>());
            _hashInvertedIndex.GetDocsContain("car").Returns(new HashSet <string>()
            {
                "1", "2", "6"
            });
            _hashInvertedIndex.GetDocsContain("evil").Returns(new HashSet <string>()
            {
                "3", "8", "4"
            });

            //Act
            var result = _sut.Search(new DocContainer()
            {
                NoSignWords = noSignWords, PlusSignWords = plusSignWords, MinusSignWords = minusSignWords
            });

            //Assert
            Assert.Equal(expected, result);
        }
 private IEnumerable <string> GetNoSignDocs(IEnumerable <string> noSignWords)
 {
     return(noSignWords.Select(x => _hashInvertedIndex.GetDocsContain(x))
            .Aggregate((a, b) => a.Intersect(b).ToHashSet()));
 }