Example #1
0
 public TimeDict(TimeDict other)
 {
     foreach (var kvp in other._dict)
     {
         _dict[kvp.Key] = kvp.Value.Copy();
     }
 }
        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"));
        }
Example #3
0
 public TimeSlice(TimeDict source, int timeStep)
 {
     _timeDict = source;
     _timeStep = timeStep;
 }