Esempio n. 1
0
        public void OrganizeDocsAndWords_ShouldReturnCorrectDictionary()
        {
            //Arrange
            var doc1 = new HashSet <string>()
            {
                "57110", "58043"
            };
            var doc2 = new HashSet <string>()
            {
                "57110"
            };
            var expected = new Dictionary <string, HashSet <string> >()
            {
                { "found", doc1 }, { "hello", doc2 }
            };
            var returnedScanData = new Dictionary <string, string>()
            {
                { "57110", "found. hello" }, { "58043", "found+" }
            };

            _docFileReader.ScanData().Returns(returnedScanData);

            //Act
            var result = _sut.OrganizeDocsAndWords();

            //Assert
            Assert.Equal(expected, result);
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            var docFileReader     = new DocFileReader("EnglishData");
            var indexCreator      = new IndexCreator(docFileReader);
            var hashInvertedIndex = new HashInvertedIndex(indexCreator.OrganizeDocsAndWords());
            var controller        = new Controller(new ConsoleView(), new Processor(hashInvertedIndex));

            controller.Run();
        }
        private static void Main(string[] args)
        {
            var context            = new SearchContextFactory().CreateDbContext(args);
            var docFileReader      = new DocFileReader();
            var documentRepository = new DocumentRepository(context);
            var indexCreator       = new IndexCreator(docFileReader, documentRepository);

            indexCreator.OrganizeDocsAndWords("EnglishData");
            var controller = new Controller(new ConsoleView(), new Processor(documentRepository));

            controller.Run();
        }
        public void OrganizeDocsAndWords_ShouldAddNewDocWithItsWords()
        {
            var returnedScanData = new Dictionary <string, string>()
            {
                { "57110", "found. hello" }, { "58043", "found+" }, { "58046", "find ++==dad soon!" }
            };

            _docFileReader.ScanData("EnglishData").Returns(returnedScanData);

            _sut.OrganizeDocsAndWords("EnglishData");
            var result   = _documentRepository.GetDocsContain("found");
            var expected = new HashSet <string>()
            {
                "57110", "58043"
            };

            Assert.Equal(expected, result);
        }