Пример #1
0
        public void TestAddRevenueKM()
        {
            //Arrange
            kmt = 100;
            PerKMRental perkmrental = new PerKMRental(kmt);
            double      expected    = 100;
            var         test        = new Vehicle(TKMT, TLP, kmserv, fuelecon);

            //Act
            double actual = test.AddRevenue(perkmrental);

            //Assert
            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        private void btnPerKM_Click(object sender, EventArgs e)
        {
            double num;
            bool   result = double.TryParse(txtJourney.Text, out num);

            if (result && num >= 0)
            {
                Journey     journey     = new Journey(num);
                PerKMRental perkmrental = new PerKMRental(num);
                //Order is important here KMserv has to be updated before TotalKM otherwise they would get different results
                Vehicles[cbVehicles.SelectedIndex].KMServ   = Vehicles[cbVehicles.SelectedIndex].AddJourney(journey);
                Vehicles[cbVehicles.SelectedIndex].TotalKMT = Vehicles[cbVehicles.SelectedIndex].AddJourney(journey);
                Vehicles[cbVehicles.SelectedIndex].Revenue  = Vehicles[cbVehicles.SelectedIndex].AddRevenue(perkmrental);
                Vehicles[cbVehicles.SelectedIndex].CalcFuelEcon();
                rtbReport.Text = Vehicles[cbVehicles.SelectedIndex].PrintToScreen() + "\n\nJourney has been added.";
            }
            else
            {
                MessageBox.Show("Please enter a valid number");
            }
        }