public void AddModifierCallsStatGraphCorrectly() { var value = Mock.Of <IValue>(); var stats = new IStat[] { new StatStub(), new StatStub() }; var modifier = MockModifier(stats, Form.More, value); var graphs = stats.ToDictionary(s => s, _ => Mock.Of <IStatGraph>()); var node = MockDisposableNodeProvider(); var nodeFactory = Mock.Of <INodeFactory>(f => f.Create(value) == node); var sut = CreateSut(s => graphs[s], nodeFactory); sut.AddModifier(modifier); Mock.Get(graphs[stats[0]]).Verify(g => g.AddModifier(node, modifier)); Mock.Get(graphs[stats[1]]).Verify(g => g.AddModifier(node, modifier)); }
public void RemoveModifierDisposesNode() { var value = Mock.Of <IValue>(); var stats = new IStat[] { new StatStub() }; var modifier = MockModifier(stats, Form.More, value); var graphs = stats.ToDictionary(s => s, _ => Mock.Of <IStatGraph>()); var node = Mock.Of <IDisposableNodeViewProvider>(p => p.DefaultView == MockNode(0) && p.SuspendableView == MockNode(0)); var nodeFactory = Mock.Of <INodeFactory>(f => f.Create(value) == node); var sut = CreateSut(s => graphs[s], nodeFactory); sut.AddModifier(modifier); sut.RemoveModifier(modifier); Mock.Get(node).Verify(n => n.Dispose()); }