コード例 #1
0
ファイル: Parcel.Tests.cs プロジェクト: atrotter0/parcel
        public void CalculateCost_CalculatesCost_Int()
        {
            Parcel package = new Parcel();

            package.SetTotalVolume(10000);
            package.SetWeight(1000);
            package.CalculateCost();
            Assert.AreEqual(110, package.GetCost());
        }
コード例 #2
0
        public void CalculateCost_XLParcel_25DollarsIsReturned(double dimensions)
        {
            //Arrange
            var parcel = new Parcel(dimensions, 10);

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(25, parcelCost.Cost);
        }
コード例 #3
0
        public void CalculateCost_HeavyParcel_50DollarsIsReturned(double dimensions)
        {
            //Arrange
            var parcel = new Parcel(dimensions, 50);

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(50, parcelCost.Cost);
        }
コード例 #4
0
        public void CalculateCost_MediumParcel_8DollarsIsReturned(double dimensions)
        {
            //Arrange
            var parcel = new Parcel(dimensions, 3);

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(8, parcelCost.Cost);
        }
コード例 #5
0
        public void CalculateCost_SmallParcelWithSpeedyShipping_6DollarsIsReturned()
        {
            //Arrange
            var parcel = new Parcel(5, 1);

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(3, parcelCost.Cost);
            Assert.Equal(6, parcelCost.SpeedyShippingCost);
        }
コード例 #6
0
        public void CalculateCost_HeavyParcelWithSpeedyShipping_100DollarsIsReturned()
        {
            //Arrange
            var parcel = new Parcel(125, 50);

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(50, parcelCost.Cost);
            Assert.Equal(100, parcelCost.SpeedyShippingCost);
        }
コード例 #7
0
        public void CalculateCost_LargeParcelWithSpeedyShipping_30DollarsIsReturned()
        {
            //Arrange
            var parcel = new Parcel(75, 6);

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(15, parcelCost.Cost);
            Assert.Equal(30, parcelCost.SpeedyShippingCost);
        }
コード例 #8
0
        public void CalculateCost_MediumParcelWithSpeedyShipping_16DollarsIsReturned()
        {
            //Arrange
            var parcel = new Parcel(25, 3);

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(8, parcelCost.Cost);
            Assert.Equal(16, parcelCost.SpeedyShippingCost);
        }
コード例 #9
0
        public void CalculateCost_HeavyParcelIsOverweight_OverweightChargeIsAddedToCostAndReturned(double weight, decimal overweightCharge)
        {
            //Arrange
            var parcel          = new Parcel(125, weight);
            var heavyParcelCost = 50;
            var expectedCost    = heavyParcelCost + overweightCharge;

            //Act
            var parcelCost = parcel.CalculateCost();

            //Assert
            Assert.Equal(expectedCost, parcelCost.Cost);
        }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: atrotter0/parcel
        public ActionResult ParcelResults(string name, int weight, int height, int length, int width)
        {
            Parcel package = new Parcel();

            package.SetSender(name);
            package.SetWeight(weight);
            package.SetHeight(height);
            package.SetLength(length);
            package.SetWidth(width);
            package.CalculateVolume();
            package.CalculateCost();
            package.SaveParcel();
            return(View(Parcel.GetAll()));
        }