コード例 #1
0
        public void TestDelayPricerProxy()
        {
            /*
             * 標準運費:以里程計
             * 其他費用:延遲五小時
             */
            decimal actual    = 0;
            var     transport = new Transport
            {
                Miles         = 200,
                Place         = "死星",
                ExtraPlaceCnt = 0,
                IsHoliday     = false,
                DelayHours    = 5
            };

            IPricer stdPricer = new MilePricer()
            {
                Customer = "達斯維達",
                Receiver = "白布丁",
                Freight  = "路克天行者"
            };

            IPricer delayPricer = new DelayPricerProxy(stdPricer);

            actual = delayPricer.Price(transport);

            var expected = (200 * 30) + 500 * 2 + 1000 * 3;

            Assert.Equal((decimal)expected, actual);
        }
コード例 #2
0
        public void TestScenario1()
        {
            /*
             * 標準運費:以里程計
             * 其他費用:加點和延遲費
             */

            var transport = new Transport
            {
                Miles         = 200,
                Place         = "台南",
                ExtraPlaceCnt = 1,
                IsHoliday     = false,
                DelayHours    = 3
            };

            IPricer stdPricer = new MilePricer()
            {
                Customer = "莉亞公主",
                Receiver = "反抗軍",
                Freight  = "死星建造圖"
            };

            IPricer extraPlacePricer = new ExtraPlacePricer(stdPricer);
            IPricer delayPricer      = new DelayPricer(extraPlacePricer);
            var     actual           = delayPricer.Price(transport);

            var expected = 200 * 30 + 200 * 30 * 0.1 + 3 * 500;

            Assert.Equal((decimal)expected, actual);
        }
コード例 #3
0
        public void TestExtraPlacePricerProxy()
        {
            /*
             * 標準運費:以里程計
             * 其他費用:加點: 3
             */
            decimal actual    = 0;
            var     transport = new Transport
            {
                Miles         = 200,
                Place         = "吉諾西斯",
                ExtraPlaceCnt = 4,
                IsHoliday     = false,
                DelayHours    = 0
            };

            IPricer stdPricer = new MilePricer()
            {
                Customer = "賽佛 迪雅",
                Receiver = "共和國",
                Freight  = "複製人軍隊"
            };

            IPricer extraPlacePricer = new ExtraPlacePricerProxy(stdPricer);

            actual = extraPlacePricer.Price(transport);

            var expected = (200 * 30) + (200 * 30) * 0.1 + ((200 * 30) * 1.1) * 0.2 * 2;

            Assert.Equal((decimal)expected, actual);
        }