예제 #1
0
        public void CanAddTrenchItems()
        {
            var rateCard = new BasicRateCard();

            var values = Enum.GetValues(typeof(EdgeType));

            var i = 0;

            foreach (var e in values)
            {
                var edgeType = (EdgeType)e;
                rateCard.AddTrenchItem(edgeType, i);
                ++i;
            }

            var firstNode  = new Node(NodeType.Cabinet);
            var secondNode = new Node(NodeType.Pot);

            i = 0;
            foreach (var e in values)
            {
                var edgeType = (EdgeType)e;
                var testEdge = new Edge(firstNode, secondNode, edgeType, 1);
                var cost     = 0;
                Assert.DoesNotThrow(() => cost = rateCard.GetEdgeCost(testEdge));
                Assert.AreEqual(i, cost);
                ++i;
            }
        }
예제 #2
0
        public void SpecificEdgeCostCalculatedCorrectly()
        {
            var rateCard = new BasicRateCard();

            rateCard.AddSpecificTrenchItem(NodeType.Cabinet, NodeType.Pot, (x) => 20 * x.DistanceMetres);

            var firstNode  = new Node(NodeType.Cabinet);
            var secondNode = new Node(NodeType.Pot);

            var testEdge = new Edge(firstNode, secondNode, EdgeType.Road, 5);
            var cost     = 0;

            Assert.DoesNotThrow(() => cost = rateCard.GetEdgeCost(testEdge));
            Assert.AreEqual(100, cost);
        }