Exemple #1
0
        public void TestIncrementalPollingSource()
        {
            var config = new ConcurrentDictionaryConfiguration();

            DynamicPropertyFactory.InitWithConfigurationSource(config);
            DynamicStringProperty prop1 = new DynamicStringProperty("prop1", null);
            DynamicStringProperty prop2 = new DynamicStringProperty("prop2", null);

            config.AddProperty("prop1", "original");
            DummyPollingSource         source    = new DummyPollingSource(true);
            FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, true);

            scheduler.IgnoreDeletesFromSource = false;
            // ConfigurationWithPollingSource pollingConfig = new ConfigurationWithPollingSource(config, source,scheduler);
            scheduler.StartPolling(source, config);
            Assert.AreEqual("original", config.GetProperty("prop1"));
            Assert.AreEqual("original", prop1.Value);
            source.SetAdded("prop2=new");
            Thread.Sleep(200);
            Assert.AreEqual("original", config.GetProperty("prop1"));
            Assert.AreEqual("new", config.GetProperty("prop2"));
            Assert.AreEqual("new", prop2.Value);
            source.SetDeleted("prop1=DoesNotMatter");
            source.SetChanged("prop2=changed");
            source.SetAdded("");
            Thread.Sleep(200);
            Assert.IsFalse(config.ContainsKey("prop1"));
            Assert.IsNull(prop1.Value);
            Assert.AreEqual("changed", config.GetProperty("prop2"));
            Assert.AreEqual("changed", prop2.Value);
        }
 public void TestIncrementalPollingSource()
 {
     var config = new ConcurrentDictionaryConfiguration();
     DynamicPropertyFactory.InitWithConfigurationSource(config);
     DynamicStringProperty prop1 = new DynamicStringProperty("prop1", null);
     DynamicStringProperty prop2 = new DynamicStringProperty("prop2", null);
     config.AddProperty("prop1", "original");
     DummyPollingSource source = new DummyPollingSource(true);
     FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, true);
     scheduler.IgnoreDeletesFromSource = false;
     // ConfigurationWithPollingSource pollingConfig = new ConfigurationWithPollingSource(config, source,scheduler);
     scheduler.StartPolling(source, config);
     Assert.AreEqual("original", config.GetProperty("prop1"));
     Assert.AreEqual("original", prop1.Value);
     source.SetAdded("prop2=new");
     Thread.Sleep(200);
     Assert.AreEqual("original", config.GetProperty("prop1"));
     Assert.AreEqual("new", config.GetProperty("prop2"));
     Assert.AreEqual("new", prop2.Value);
     source.SetDeleted("prop1=DoesNotMatter");
     source.SetChanged("prop2=changed");
     source.SetAdded("");
     Thread.Sleep(200);
     Assert.IsFalse(config.ContainsKey("prop1"));
     Assert.IsNull(prop1.Value);
     Assert.AreEqual("changed", config.GetProperty("prop2"));
     Assert.AreEqual("changed", prop2.Value);
 }
Exemple #3
0
        public void TestNoneDeletingPollingSource()
        {
            var config = new ConcurrentDictionaryConfiguration();

            config.AddProperty("prop1", "original");
            DummyPollingSource source = new DummyPollingSource(false);

            source.SetFull("");
            FixedDelayPollingScheduler     scheduler     = new FixedDelayPollingScheduler(0, 10, true);
            ConfigurationWithPollingSource pollingConfig = new ConfigurationWithPollingSource(config, source, scheduler);

            Thread.Sleep(200);
            Assert.AreEqual("original", pollingConfig.GetProperty("prop1"));
            source.SetFull("prop1=changed");
            Thread.Sleep(200);
            Assert.AreEqual("changed", pollingConfig.GetProperty("prop1"));
            source.SetFull("prop1=changedagain,prop2=new");
            Thread.Sleep(200);
            Assert.AreEqual("changedagain", pollingConfig.GetProperty("prop1"));
            Assert.AreEqual("new", pollingConfig.GetProperty("prop2"));
            source.SetFull("prop3=new");
            Thread.Sleep(200);
            Assert.AreEqual("changedagain", pollingConfig.GetProperty("prop1"));
            Assert.AreEqual("new", pollingConfig.GetProperty("prop2"));
            Assert.AreEqual("new", pollingConfig.GetProperty("prop3"));
        }
 public void TestNoneDeletingPollingSource()
 {
     var config = new ConcurrentDictionaryConfiguration();
     config.AddProperty("prop1", "original");
     DummyPollingSource source = new DummyPollingSource(false);
     source.SetFull("");
     FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, true);
     ConfigurationWithPollingSource pollingConfig = new ConfigurationWithPollingSource(config, source, scheduler);
     Thread.Sleep(200);
     Assert.AreEqual("original", pollingConfig.GetProperty("prop1"));
     source.SetFull("prop1=changed");
     Thread.Sleep(200);
     Assert.AreEqual("changed", pollingConfig.GetProperty("prop1"));
     source.SetFull("prop1=changedagain,prop2=new");
     Thread.Sleep(200);
     Assert.AreEqual("changedagain", pollingConfig.GetProperty("prop1"));
     Assert.AreEqual("new", pollingConfig.GetProperty("prop2"));
     source.SetFull("prop3=new");
     Thread.Sleep(200);
     Assert.AreEqual("changedagain", pollingConfig.GetProperty("prop1"));
     Assert.AreEqual("new", pollingConfig.GetProperty("prop2"));
     Assert.AreEqual("new", pollingConfig.GetProperty("prop3"));
 }