예제 #1
0
        public void AccumulateKeepsTwiceAddedModifierTwice()
        {
            var modifiers = Helper.MockManyModifiers(4);
            var expected  = new CalculatorUpdate(new[] { modifiers[0], modifiers[0] }, new Modifier[0]);

            var actual = CalculatorUpdate.Accumulate(expected, CalculatorUpdate.Empty);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void AccumulateRemovesWhenRemovedAndAddedInSameUpdate()
        {
            var modifiers = Helper.MockManyModifiers(4);
            var l         =
                new CalculatorUpdate(new[] { modifiers[0], modifiers[1] }, new[] { modifiers[1], modifiers[2] });
            var expected = new CalculatorUpdate(new[] { modifiers[0] }, new[] { modifiers[2] });

            var actual = CalculatorUpdate.Accumulate(l, CalculatorUpdate.Empty);

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void AccumulateRemovesWhenAddedInFirstAndRemovedInSecondUpdate()
        {
            var modifiers = Helper.MockManyModifiers(4);
            var l         = new CalculatorUpdate(new[] { modifiers[0] }, new[] { modifiers[2] });
            var r         = new CalculatorUpdate(new[] { modifiers[1] }, new[] { modifiers[0] });
            var expected  = new CalculatorUpdate(new[] { modifiers[1] }, new[] { modifiers[2] });

            var actual = CalculatorUpdate.Accumulate(l, r);

            Assert.AreEqual(expected, actual);
        }
예제 #4
0
        public void AccumulateCombinesDistinctUpdatesCorrectly()
        {
            var modifiers = Helper.MockManyModifiers(4);
            var l         = new CalculatorUpdate(new[] { modifiers[0] }, new[] { modifiers[1] });
            var r         = new CalculatorUpdate(new[] { modifiers[2] }, new[] { modifiers[3] });
            var expected  =
                new CalculatorUpdate(new[] { modifiers[0], modifiers[2] }, new[] { modifiers[1], modifiers[3] });

            var actual = CalculatorUpdate.Accumulate(l, r);

            Assert.AreEqual(expected, actual);
        }
 public void Update(CalculatorUpdate update)
 {
     _eventBuffer.StartBuffering();
     foreach (var modifier in update.RemovedModifiers)
     {
         _modifierCollection.RemoveModifier(modifier);
     }
     foreach (var modifier in update.AddedModifiers)
     {
         _modifierCollection.AddModifier(modifier);
     }
     _graphPruner.RemoveUnusedNodes();
     _eventBuffer.Flush();
     _eventBuffer.StopBuffering();
 }