コード例 #1
0
        public void RequestedCargoBoundaryTest()
        {
            //Variables
            var reqCargo = new RequestedCargo();

            // Try Catch block to test the fail condition
            try
            {
                // Setting the cargoVolume to a 0.0001
                reqCargo.SetCargoVolume(0.0001);
                Assert.AreEqual(0.0001, reqCargo.GetCargoVolume());

                // Setting the cargoVolume to a 0.000001
                reqCargo.SetCargoVolume(0.00001);
                Assert.AreEqual(0.00001, reqCargo.GetCargoVolume());
            }
            catch (Exception e)
            {
                // Asserting that Test Failed
                Assert.AreNotEqual("Invalid Cargo Volume", e.Message);
            }

            try
            {
                //Testing Failed Boundary for -0.0001
                reqCargo.SetCargoVolume(-0.0001);
            }
            catch (Exception e)
            {
                Assert.AreEqual("Invalid Cargo Volume", e.Message);
            }

            try
            {
                //Testing Failed Boundary for -0.00001
                reqCargo.SetCargoVolume(-0.00001);
            }
            catch (Exception e)
            {
                Assert.AreEqual("Invalid Cargo Volume", e.Message);
            }
        }
コード例 #2
0
        public void RequestedCargoExceptionTest()
        {
            //Variables
            var reqCargo = new RequestedCargo();

            // Try Catch block to test the fail condition
            try
            {
                // Setting the cargoVolume to an invalid amount
                reqCargo.SetCargoVolume(-1.0);
            }
            catch (Exception e)
            {
                // Determining if the fail condition succeeded
                Assert.AreEqual("Invalid Cargo Volume", e.Message);
            }
        }