public void TimeDictTest()
        {
            TimeDict history = new TimeDict();

            Assert.AreEqual(false, history.Get <bool>(0, "test")); // no value should return template type default

            history.Set(10, "int_var", 55);
            Assert.AreEqual(0, history.Get <int>(0, "int_var"));   // before point still 0
            Assert.AreEqual(55, history.Get <int>(10, "int_var")); // at point is 55
            Assert.AreEqual(55, history.Get <int>(20, "int_var")); // after point is 55

            Assert.AreEqual(0, history[0].Get <int>("int_var"));

            history.Set(25, "int_var", 1111);
            Assert.AreEqual(55, history.Get <int>(15, "int_var"));
            Assert.AreEqual(1111, history.Get <int>(25, "int_var"));
            Assert.AreEqual(1111, history.Get <int>(30, "int_var"));

            history.Set(5, "int_var", 333, force: true, clearFuture: true);
            Assert.AreEqual(0, history.Get <int>(0, "int_var"));        // before is still 0
            Assert.AreEqual(333, history.Get <int>(10, "int_var"));     // rest are 333 because of clearFuture
            Assert.AreEqual(333, history.Get <int>(15, "int_var"));
            Assert.AreEqual(333, history.Get <int>(25, "int_var"));
            Assert.AreEqual(333, history.Get <int>(30, "int_var"));
        }
Beispiel #2
0
 public void Set <T>(string key, T value, bool force = false, bool clearFuture = false) where T : IEquatable <T> => _timeDict.Set(_timeStep, key, value, force, clearFuture);