Example #1
0
        public void Setup()
        {
            _left = Mock.Interface<ICalculationNode>();
            _right = Mock.Interface<ICalculationNode>();

            _substractionNode = new SubstractionNode(_left, _right);
        }
Example #2
0
        public void Setup()
        {
            _left = Mock.Interface<ICalculationNode>();
            _right = Mock.Interface<ICalculationNode>();

            _additionNode = new AdditionNode(_left, _right);
        }
Example #3
0
 public CachingNode(ICalculationNode decoratedNode, ICycleGuard cycleGuard, IEventBuffer eventBuffer)
 {
     _decoratedNode = decoratedNode;
     _cycleGuard    = cycleGuard;
     _eventBuffer   = eventBuffer;
     _decoratedNode.ValueChanged += DecoratedNodeOnValueChanged;
 }
        public void Setup()
        {
            _left = Mock.Interface<ICalculationNode>();
            _right = Mock.Interface<ICalculationNode>();

            _multiplicationNode = new MultiplicationNode(_left, _right);
        }
Example #5
0
 public static IBufferingEventViewProvider <ICalculationNode> MockNodeProvider(
     ICalculationNode defaultNode = null, ICalculationNode bufferingView = null)
 {
     defaultNode   = defaultNode ?? MockNode();
     bufferingView = bufferingView ?? MockNode();
     return(Mock.Of <IBufferingEventViewProvider <ICalculationNode> >(
                p => p.DefaultView == defaultNode && p.BufferingView == bufferingView));
 }
Example #6
0
 private void Evaluate(ICalculationNode node)
 {
     foreach (var child in node.Children)
     {
         var     childDomainItem = child.ToDomainItem(m_domainItemLocator);
         dynamic d = childDomainItem;
         Evaluate(d);
     }
 }
Example #7
0
 public static ISuspendableEventViewProvider <ICalculationNode> MockNodeProvider(
     ICalculationNode defaultNode = null, ICalculationNode suspendableNode = null,
     ISuspendableEvents suspender = null)
 {
     defaultNode     = defaultNode ?? MockNode();
     suspendableNode = suspendableNode ?? MockNode();
     suspender       = suspender ?? Mock.Of <ISuspendableEvents>();
     return(Mock.Of <ISuspendableEventViewProvider <ICalculationNode> >(
                p => p.DefaultView == defaultNode && p.SuspendableView == suspendableNode && p.Suspender == suspender));
 }
Example #8
0
        protected void Add(ICalculationNode node, IStat stat)
        {
            if (TryGetStatViewModel(stat, out _))
            {
                return;
            }

            var statVm = CreateViewModel(node, stat);

            Stats.Add(statVm);
        }
Example #9
0
        private static ValueNode CreateSut(ICalculationNode node1, ICalculationNode node2)
        {
            var stat1          = new StatStub();
            var stat2          = new StatStub();
            var nodeRepository = Mock.Of <INodeRepository>(r =>
                                                           r.GetNode(stat1, NodeType.Total, Path) == node1 &&
                                                           r.GetNode(stat2, NodeType.Base, Path) == node2);
            var valueMock = new Mock <IValue>();

            valueMock.Setup(v => v.Calculate(It.IsAny <IValueCalculationContext>()))
            .Returns((IValueCalculationContext c) => c.GetValue(stat1) + c.GetValue(stat2, NodeType.Base));
            return(CreateSut(nodeRepository, valueMock.Object));
        }
Example #10
0
 protected abstract T CreateViewModel(ICalculationNode node, IStat stat);
Example #11
0
 public CachingNode(ICalculationNode decoratedNode, ICycleGuard cycleGuard)
 {
     _decoratedNode = decoratedNode;
     _cycleGuard    = cycleGuard;
     _decoratedNode.ValueChanged += DecoratedNodeOnValueChanged;
 }
Example #12
0
 private static CachingNode CreateSut(ICalculationNode decoratedNode, ICycleGuard cycleGuard = null)
 {
     return(new CachingNode(decoratedNode, cycleGuard ?? Mock.Of <ICycleGuard>()));
 }
Example #13
0
 private static CachingNode CreateSut(
     ICalculationNode decoratedNode, ICycleGuard cycleGuard = null, IEventBuffer eventBuffer = null)
 => new CachingNode(decoratedNode, cycleGuard ?? Mock.Of <ICycleGuard>(), eventBuffer ?? new EventBuffer());
Example #14
0
 private static WrappingNode CreateSut(ICalculationNode decoratedNode = null) =>
 new WrappingNode(decoratedNode ?? NodeHelper.MockNode());
Example #15
0
 protected BinaryOperationNode([NotNull] ICalculationNode left, [NotNull] ICalculationNode right)
 {
     Left = left;
     Right = right;
 }
Example #16
0
 public static void AssertValueChangedWillNotBeInvoked(this ICalculationNode node) =>
 node.SubscribeToValueChanged(Assert.Fail);
        protected override ResultNodeViewModel CreateViewModel(ICalculationNode node, IStat stat)
        {
            var nodeType = ((ExplicitRegistrationType.IndependentResult)stat.ExplicitRegistrationType).ResultType;

            return(_nodeFactory.CreateResult(stat, nodeType));
        }
Example #18
0
 public void Setup()
 {
     _value = Mock.Interface<ICalculationNode>();
     _absoluteNode = new AbsoluteNode(_value);
 }
Example #19
0
 public WrappingNode(ICalculationNode decoratedNode)
 {
     _decoratedNode = decoratedNode;
     _decoratedNode.ValueChanged += OnValueChanged;
 }
Example #20
0
 public static void AssertValueEquals(this ICalculationNode node, double?expected) =>
 Assert.AreEqual((NodeValue?)expected, node.Value);
Example #21
0
 public static void SubscribeToValueChanged(this ICalculationNode node, Action handler) =>
 node.ValueChanged += (sender, args) =>
 {
     Assert.AreEqual(node, sender);
     handler();
 };
Example #22
0
 public void Setup()
 {
     _value = Mock.Interface<ICalculationNode>();
     _node = new SignNode(_value);
 }
Example #23
0
 public decimal Evaluate(ICalculationNode node)
 {
     return(m_calculationVisitor.Calculate(new DomainId <ICalculationNode>(node.Id)));
 }
Example #24
0
 public void Setup()
 {
     _value = Mock.Interface<ICalculationNode>();
     _squareRootNode = new SquareRootNode(_value);
 }