Esempio n. 1
0
        public void CalculateTest()
        {
            // 從整合測試的test case,來當做單元測試的test case

            // arrange
            PostOffice target = new PostOffice()
            {
                ShipProduct = new Product
                {
                    IsNeedCool = true,
                    Name       = "商品測試1",
                    Size       = new Size
                    {
                        Height = 10,
                        Length = 30,
                        Width  = 20
                    },
                    Weight = 10
                }
            };

            // act
            target.Calculate();

            var expectedName = "郵局";
            var expectedFee  = 180;

            var actualName = target.GetsComapanyName();
            var actualFee  = target.GetsFee();

            // assert
            Assert.AreEqual(expectedName, actualName);
            Assert.AreEqual(expectedFee, actualFee);
        }
Esempio n. 2
0
        public void CalculateTest_PostOffice()
        {
            PostOffice target = new PostOffice()
            {
                ShipProduct = new Product
                {
                    IsNeedCool = true,
                    Name       = "test1",
                    Size       = new getSize
                    {
                        Height = 10,
                        Length = 30,
                        Width  = 20
                    },
                    Weight = 10
                }
            };

            target.Calculate();

            var expectedName = "PostOffice";
            var expectedFee  = 180;

            var actualName = target.GetsCompanyName();
            var actualFee  = target.GetsFee();

            Assert.AreEqual(expectedName, actualName);
            Assert.AreEqual(expectedFee, actualFee);
        }