Exemple #1
0
        public void GetPathReturnsInjectedPathsDefaultView()
        {
            var expected        = Mock.Of <IObservableCollection <PathDefinition> >();
            var stat            = Mock.Of <IStat>();
            var graphCollection = Mock.Of <IStatGraphCollection>(
                c => c.GetOrAdd(stat).Paths.SuspendableView == expected);
            var sut = new SuspendableViewNodeRepository(graphCollection);

            var actual = sut.GetPaths(stat);

            Assert.AreSame(actual, expected);
        }
Exemple #2
0
        public void SuspendableViewGetNodeReturnsInjectedGetNodesSuspendableView()
        {
            var expected        = Mock.Of <ICalculationNode>();
            var stat            = Mock.Of <IStat>();
            var path            = PathDefinition.MainPath;
            var graphCollection = Mock.Of <IStatGraphCollection>(
                c => c.GetOrAdd(stat).GetNode(new NodeSelector(NodeType.Total, path)).SuspendableView == expected);
            var sut = new SuspendableViewNodeRepository(graphCollection);

            var actual = sut.GetNode(stat, NodeType.Total, path);

            Assert.AreSame(expected, actual);
        }
Exemple #3
0
        public void SuspendableViewGetFormNodeCollectionReturnsInjectedGetFormNodeCollectionsSuspendableView()
        {
            var expected        = Mock.Of <INodeCollection <Modifier> >();
            var stat            = Mock.Of <IStat>();
            var path            = PathDefinition.MainPath;
            var graphCollection = Mock.Of <IStatGraphCollection>(
                c => c.GetOrAdd(stat).GetFormNodeCollection(new FormNodeSelector(Form.BaseAdd, path)).SuspendableView
                == expected);
            var sut = new SuspendableViewNodeRepository(graphCollection);

            var actual = sut.GetFormNodeCollection(stat, Form.BaseAdd, path);

            Assert.AreSame(expected, actual);
        }
Exemple #4
0
        /// <summary>
        /// Creates an <see cref="ICalculator"/>.
        /// </summary>
        public static ICalculator CreateCalculator()
        {
            var innerNodeFactory       = new NodeFactory();
            var nodeFactory            = new TransformableNodeFactory(innerNodeFactory, v => new TransformableValue(v));
            var statRegistryCollection = new NodeCollection <IStat>();
            var statRegistry           = new StatRegistry(statRegistryCollection);
            var valueTransformer       = new ValueTransformer();

            var prunableGraph = CreateCalculationGraph(nodeFactory, statRegistry, valueTransformer);

            var defaultView     = new DefaultViewNodeRepository(prunableGraph);
            var suspendableView = new SuspendableViewNodeRepository(prunableGraph);

            innerNodeFactory.NodeRepository = defaultView;
            statRegistry.NodeRepository     = suspendableView;

            var suspender = new SuspendableEventsComposite();

            suspender.Add(new StatGraphCollectionSuspender(prunableGraph));
            suspender.Add(statRegistryCollection);

            return(new Calculator(suspender, prunableGraph, prunableGraph, suspendableView, statRegistryCollection));
        }