Exemple #1
0
        public void TestUpdateWithoutDependency()
        {
            DependencySystem<object> test = new DependencySystem<object>();
            object a = 1;
            object b = 2;
            test.AddDependency(b, a);
            test.Invalidate(b);

            Assert.False(test.NeedsUpdate);
        }
Exemple #2
0
        public void TestSimpleUpdate()
        {
            DependencySystem<object> test = new DependencySystem<object>();
            object a = 1;
            object b = 2;
            test.AddDependency(b, a);

            Assert.False(test.NeedsUpdate);

            test.Invalidate(a);

            List<DependencySystem<object>.InvalidDependent> updates = new List<DependencySystem<object>.InvalidDependent>(test.GetInvalidDependents());
            Assert.AreEqual(updates.Count, 1);
            TestUpdate(updates[0], b, a);

            Assert.False(test.NeedsUpdate);
        }
Exemple #3
0
        public void TestUpdate()
        {
            DependencySystem<object> test = new DependencySystem<object>();
            object a = 1;
            object b = 2;
            object c = 3;
            object d = 4;
            test.AddDependency(d, c);
            test.AddDependency(c, b);
            test.AddDependency(b, a);

            Assert.False(test.NeedsUpdate);

            test.Invalidate(a);

            List<DependencySystem<object>.InvalidDependent> updates = new List<DependencySystem<object>.InvalidDependent>(test.GetInvalidDependents());
            Assert.AreEqual(updates.Count, 3);
            TestUpdate(updates[0], b, a);
            TestUpdate(updates[1], c, b);
            TestUpdate(updates[2], d, c);
        }
Exemple #4
0
 private void TestUpdate(DependencySystem<object>.InvalidDependent update, object dependent, params object[] dependencies)
 {
     Assert.AreEqual(update.Dependent, dependent);
     Utilities.TestSequenceContainSameItems(update.Dependencies, dependencies);
 }
Exemple #5
0
 public void TestEmpty()
 {
     DependencySystem<object> test = new DependencySystem<object>();
     Assert.False(test.NeedsUpdate);
     CollectionAssert.IsEmpty(test.GetInvalidDependents());
 }
Exemple #6
0
 /// <summary>
 /// Sets the stored value.
 /// </summary>
 public void SetValue(DependencySystem system, object value)
 {
     this.value = value;
     ChangedAt  = system.GetNextRevision();
 }