Пример #1
0
 public void RemoveFormNodeCollection(FormNodeSelector selector)
 {
     if (_formNodeCollections.Remove(selector))
     {
         _paths.Remove(selector.Path);
     }
 }
        public void RemoveUnusedNodesRemovesRemainingModifiers()
        {
            var stat          = new StatStub();
            var modifier      = MockModifier(stat);
            var statGraphMock = new Mock <IStatGraph>();
            var ruleSet       = Mock.Of <IGraphPruningRuleSet>(r =>
                                                               r.CanStatBeConsideredForRemoval(stat, statGraphMock.Object) &&
                                                               r.CanStatGraphBeRemoved(statGraphMock.Object));
            var formNodeSelector       = new FormNodeSelector(Form.TotalOverride, PathDefinition.MainPath);
            var modifierNodeCollection = new StatNodeFactory(new EventBuffer(), null !, stat)
                                         .Create(formNodeSelector);

            modifierNodeCollection.Add(MockProvider <ICalculationNode>(), modifier);
            var formNodeCollection =
                new Dictionary <FormNodeSelector, IBufferingEventViewProvider <INodeCollection <Modifier> > >
            {
                { new FormNodeSelector(Form.TotalOverride, PathDefinition.MainPath), modifierNodeCollection }
            };

            statGraphMock.SetupGet(g => g.FormNodeCollections).Returns(formNodeCollection);
            var graphMock = MockGraph(stat, statGraphMock.Object);
            var sut       = CreateSut(graphMock.Object, ruleSet);

            sut.StatAdded(stat);

            sut.RemoveUnusedNodes();

            graphMock.Verify(g => g.RemoveModifier(modifier));
            statGraphMock.Verify(g => g.RemoveFormNodeCollection(formNodeSelector));
            graphMock.Verify(g => g.Remove(stat));
        }
Пример #3
0
        public void AddModifierUsesCorrectPath()
        {
            var node       = MockNodeProvider();
            var source     = new ModifierSource.Global(new ModifierSource.Local.Given());
            var modifier   = MockModifier(source: source);
            var collection = CreateModifierNodeCollection();
            var selector   = new FormNodeSelector(modifier.Form, new PathDefinition(source.CanonicalSource));
            var factory    = Mock.Of <IStatNodeFactory>(f => f.Create(selector) == collection);
            var sut        = CreateSut(factory);

            sut.AddModifier(node, modifier);

            CollectionAssert.Contains(collection.DefaultView, (node.DefaultView, modifier));
        }
Пример #4
0
 GetFormNodeCollection(FormNodeSelector selector) =>
 GetModifierNodeCollection(selector);
Пример #5
0
 private ModifierNodeCollection CreateModifierNodeCollection(FormNodeSelector selector)
 {
     _paths.Add(selector.Path);
     return(_nodeFactory.Create(selector));
 }
Пример #6
0
 private ModifierNodeCollection GetModifierNodeCollection(FormNodeSelector selector) =>
 (ModifierNodeCollection)_formNodeCollections.GetOrAdd(selector, CreateModifierNodeCollection);
Пример #7
0
 public void RemoveFormNodeCollection(FormNodeSelector selector) =>
 _decoratedGraph.RemoveFormNodeCollection(selector);
Пример #8
0
 public IBufferingEventViewProvider <INodeCollection <Modifier> > GetFormNodeCollection(FormNodeSelector selector) =>
 _decoratedGraph.GetFormNodeCollection(selector);