public void TestEditIndexConfig()
        {
            using var configBuilder = new ConfigIndexBuilder(TempConfigDir);

            var config1 = new IndexConfig
            {
                IndexName = "ABC"
            };

            var config2 = new IndexConfig
            {
                IndexName = "EFG"
            };

            configBuilder.AddIndexConfig(config1);
            configBuilder.AddIndexConfig(config2);
            Assert.AreEqual(2, configBuilder.GetConfigs().Count());

            config1.IndexName = "NEW";
            configBuilder.EditIndexConfig(config1);
            CollectionAssert.AreEquivalent(new[] { "NEW", "EFG" }, configBuilder.GetConfigs().Select(u => u.IndexName));

            config2.IndexName = "NEW NEW";
            configBuilder.EditIndexConfig(config2);
            CollectionAssert.AreEquivalent(new[] { "NEW", "NEW NEW" }, configBuilder.GetConfigs().Select(u => u.IndexName));
        }
        public void TestGetConfigs()
        {
            using var configBuilder = new ConfigIndexBuilder(TempConfigDir);
            configBuilder.AddIndexConfig(new IndexConfig
            {
                IndexName = "ABC"
            });

            Assert.AreEqual("ABC", configBuilder.GetConfigs().First().IndexName);
        }
        public void TestAddIndexConfig()
        {
            using var configBuilder = new ConfigIndexBuilder(TempConfigDir);
            configBuilder.AddIndexConfig(new IndexConfig
            {
                IndexName = "ABC"
            });

            Assert.AreEqual("ABC", configBuilder.GetConfigs().First().IndexName);

            configBuilder.AddIndexConfig(new IndexConfig
            {
                IndexName = "EFG"
            });

            CollectionAssert.AreEquivalent(new[] { "ABC", "EFG" }, configBuilder.GetConfigs().Select(u => u.IndexName));
        }
Exemple #4
0
        public ConfigIndexMaintainer(CodeIndexConfiguration codeIndexConfiguration, ILogger log)
        {
            codeIndexConfiguration.RequireNotNull(nameof(codeIndexConfiguration));
            log.RequireNotNull(nameof(log));

            CodeIndexConfiguration = codeIndexConfiguration;
            Log = log;

            var folder = Path.Combine(codeIndexConfiguration.LuceneIndex, CodeIndexConfiguration.ConfigurationIndexFolder);

            if (!Directory.Exists(folder))
            {
                Log.LogInformation($"Create Configuraion index folder {folder}");
                Directory.CreateDirectory(folder);
            }

            ConfigIndexBuilder = new ConfigIndexBuilder(folder);
        }
        public void TestConvert()
        {
            var document = new Document
            {
                new StringField(nameof(DummyForTest.Pk), Guid.NewGuid().ToString(), Field.Store.YES),
                new StringField(nameof(DummyForTest.AAA), "AAA", Field.Store.YES),
                new StringField(nameof(DummyForTest.BBB), "32", Field.Store.YES),
                new StringField(nameof(DummyForTest.CCC), "32.3", Field.Store.YES),
                new StringField(nameof(DummyForTest.DDD), "120.0", Field.Store.YES),
                new Int64Field(nameof(DummyForTest.EEE), DateTime.Now.Ticks, Field.Store.YES),
                new StringField(nameof(DummyForTest.FFF), "A|B|C|D|E", Field.Store.YES),
                new StringField(nameof(DummyForTest.ReadonlyProperty), "ReadonlyProperty", Field.Store.YES),
            };

            var dummyForTest = document.GetObject <DummyForTest>();

            Assert.AreNotEqual(Guid.Empty, dummyForTest.Pk);
            Assert.AreEqual("AAA", dummyForTest.AAA);
            Assert.AreEqual(32, dummyForTest.BBB);
            Assert.AreEqual(32.3, dummyForTest.CCC);
            Assert.AreEqual(120.0f, dummyForTest.DDD);
            Assert.AreNotEqual(new DateTime(), dummyForTest.EEE);
            CollectionAssert.AreEquivalent(new[] { "A", "B", "C", "D", "E" }, dummyForTest.FFF);
            Assert.IsNull(dummyForTest.ReadonlyProperty, "Don't set readonly property");

            var config = new IndexConfig
            {
                ExcludedExtensions        = "ABC",
                ExcludedPaths             = "CDF",
                IncludedExtensions        = "QQQ",
                IndexName                 = "AAA",
                MaxContentHighlightLength = 100,
                MonitorFolder             = "BCD",
                MonitorFolderRealPath     = "SSS",
                OpenIDEUriFormat          = "DDDD",
                SaveIntervalSeconds       = 22,
                Pk = Guid.NewGuid()
            };

            document = ConfigIndexBuilder.GetDocument(config);
            Assert.AreEqual(config.ToString(), document.GetObject <IndexConfig>().ToString());
        }
        public void TestGetDocumet()
        {
            var config = new IndexConfig
            {
                ExcludedExtensions        = "ABC",
                ExcludedPaths             = "CDF",
                IncludedExtensions        = "QQQ",
                IndexName                 = "AAA",
                MaxContentHighlightLength = 100,
                MonitorFolder             = "BCD",
                MonitorFolderRealPath     = "SSS",
                OpenIDEUriFormat          = "DDDD",
                SaveIntervalSeconds       = 22,
                Pk = Guid.NewGuid()
            };

            var document = ConfigIndexBuilder.GetDocument(config);

            Assert.AreEqual(10, document.Fields.Count);

            var configConvertBack = document.GetObject <IndexConfig>();

            Assert.AreEqual(config.ToString(), configConvertBack.ToString());
        }
Exemple #7
0
 public void EditIndexConfig(IndexConfig indexConfig)
 {
     ConfigIndexBuilder.EditIndexConfig(indexConfig);
 }
Exemple #8
0
 public void DeleteIndexConfig(Guid pk)
 {
     ConfigIndexBuilder.DeleteIndexConfig(pk);
 }
Exemple #9
0
 public void AddIndexConfig(IndexConfig indexConfig)
 {
     ConfigIndexBuilder.AddIndexConfig(indexConfig);
 }
Exemple #10
0
 public IEnumerable <IndexConfig> GetConfigs()
 {
     return(ConfigIndexBuilder.GetConfigs());
 }