Exemplo n.º 1
0
        public void GetAllDocuments_ShouldReturnSomeDocs_WhenPathIsOk()
        {
            var returnedScanData = new Dictionary <string, string>()
            {
                { "57110", "found. hello" }, { "58043", "found+" }
            };

            _fileReader.ScanData(It.IsAny <string>()).Returns(returnedScanData);

            var expected = new List <Doc>()
            {
                new Doc()
                {
                    Name    = "57110",
                    Content = "found. hello"
                },
                new Doc()
                {
                    Name    = "58043",
                    Content = "found+"
                }
            };

            var result = _sut.GetAllDocuments(It.IsAny <string>());

            Assert.Equal(expected, result);
        }
        private static void Main(string[] args)
        {
            IConfiguration config        = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            var            directoryPath = config.GetValue <string>("DirectoryPath");

            var client       = new ElasticClientFactory(config).CreateElasticClient();
            var queryCreator = new QueryCreator();
            var searcher     = new Searcher(client, queryCreator, Index);

            var consoleView = new ConsoleView();
            var controller  = new Controller(consoleView, searcher);

            if (!IsIndexExisting(Index, client))
            {
                var indexCreator = new IndexCreator(client);
                indexCreator.CreateIndex(Index);
                var fileReader = new DocFileReader();
                var docCreator = new DocFactory(fileReader);
                var importer   = new Importer <Doc>(client);
                importer.Import(docCreator.GetAllDocuments(directoryPath), Index);
            }
            controller.Run();
        }