public void Rental_isJourneyRentableCheckMakeYear_AssertEquals() { //Arrange //Get data fom SQL Object[] data = SQLConnector.LoadAll("user id = cars; persistsecurityinfo = True; server = localhost; database = cars_test; password=Password1;"); List <Vehicle> vehicleData = (List <Vehicle>)data[0]; //put list from object in here List <Service> serviceData = (List <Service>)data[1]; List <Journey> journeyData = (List <Journey>)data[2]; //Act //Create Rentals Rental R0 = new Rental(vehicleData[0], journeyData, serviceData); Rental R1 = new Rental(vehicleData[1], journeyData, serviceData); Rental R2 = new Rental(vehicleData[2], journeyData, serviceData); //Create Journey for each car Journey J0 = new Journey(600, new DateTime(2018, 4, 3), DateTime.Now, DateTime.Now, R0.getVehicle().getVehicleID(), false); Journey J1 = new Journey(400, new DateTime(2018, 4, 3), DateTime.Now, DateTime.Now, R1.getVehicle().getVehicleID(), false); Journey J2 = new Journey(-100, new DateTime(2018, 4, 3), DateTime.Now, DateTime.Now, R2.getVehicle().getVehicleID(), false); //Get rentability Boolean[] rentable0 = R0.isJourneyRentable(J0); Boolean[] rentable1 = R1.isJourneyRentable(J1); Boolean[] rentable2 = R2.isJourneyRentable(J2); //Assert //Check if after or before make year (after make year, rentable[2] = true) Assert.AreEqual(true, rentable0[2]); //Journey is after make year, car is exists Assert.AreEqual(true, rentable1[2]); //Journey is after make year, car is exists Assert.AreEqual(false, rentable2[2]); //Journey is before make year, Can't rent }
public void Rental_isJourneyRentableInvalidLength_AssertEquals() { //Arrange //Get data fom SQL Object[] data = SQLConnector.LoadAll("user id = cars; persistsecurityinfo = True; server = localhost; database = cars_test; password=Password1;"); List <Vehicle> vehicleData = (List <Vehicle>)data[0]; //put list from object in here List <Service> serviceData = (List <Service>)data[1]; List <Journey> journeyData = (List <Journey>)data[2]; //Act //Create Rentals Rental R0 = new Rental(vehicleData[0], journeyData, serviceData); Rental R1 = new Rental(vehicleData[1], journeyData, serviceData); Rental R2 = new Rental(vehicleData[2], journeyData, serviceData); //Create Journey for each car Journey J0 = new Journey(600, new DateTime(2018, 4, 3), DateTime.Now, DateTime.Now, R0.getVehicle().getVehicleID(), false); Journey J1 = new Journey(400, new DateTime(2018, 4, 3), DateTime.Now, DateTime.Now, R1.getVehicle().getVehicleID(), false); Journey J2 = new Journey(-100, new DateTime(2018, 4, 3), DateTime.Now, DateTime.Now, R2.getVehicle().getVehicleID(), false); //Get rentability Boolean[] rentable0 = R0.isJourneyRentable(J0); Boolean[] rentable1 = R1.isJourneyRentable(J1); Boolean[] rentable2 = R2.isJourneyRentable(J2); //Assert //Check if journey length is okay (rentable[3] = true) Assert.AreEqual(false, rentable0[3]); //Longer than journey limit (500) can't rent Assert.AreEqual(true, rentable1[3]); //Less than journey limit, can rent Assert.AreEqual(false, rentable2[3]); //negativ number, can't rent }
public void LoadAll_DataNotNull_ReturnsTrue() { //Arrange //Get data from SQL Object[] data = SQLConnector.LoadAll("user id = cars; persistsecurityinfo = True; server = localhost; database = cars_test; password=Password1;"); //Act //Do nothing //Assert Assert.IsNotNull(data); }
public void Vehicle_isRegistrationValid_AssertsEquals() { //Arrange //Get data fom SQL Object[] data = SQLConnector.LoadAll("user id = cars; persistsecurityinfo = True; server = localhost; database = cars_test; password=Password1;"); List <Vehicle> vehicleData = (List <Vehicle>)data[0]; //put list from object in here //Act //Create Vehicles Vehicle V0 = vehicleData[0]; Vehicle V1 = vehicleData[1]; Vehicle V2 = vehicleData[2]; //Assert //Check vehicle details Assert.AreEqual(true, V0.isRegistrationValid()); Assert.AreEqual(false, V1.isRegistrationValid()); Assert.AreEqual(false, V2.isRegistrationValid()); }
public void Details_CheckModel_AssertsEqualsTrue() { //Arrange //Get data fom SQL Object[] data = SQLConnector.LoadAll("user id = cars; persistsecurityinfo = True; server = localhost; database = cars_test; password=Password1;"); List <Vehicle> vehicleData = (List <Vehicle>)data[0]; //put list from object in here List <Service> serviceData = (List <Service>)data[1]; List <Journey> journeyData = (List <Journey>)data[2]; //Act //Create Details Details D0 = new Details(vehicleData[0], serviceData, journeyData); Details D1 = new Details(vehicleData[1], serviceData, journeyData); Details D2 = new Details(vehicleData[2], serviceData, journeyData); //Assert //Check vehicle details Assert.AreEqual("Fiesta 2010", D0.getModel()); Assert.AreEqual("Barina 2015", D1.getModel()); Assert.AreEqual("Mito 2019", D2.getModel()); }
public void Details_CheckDistanceTravelled_AssertsEqualsTrue() { //Arrange //Get data fom SQL Object[] data = SQLConnector.LoadAll("user id = cars; persistsecurityinfo = True; server = localhost; database = cars_test; password=Password1;"); List <Vehicle> vehicleData = (List <Vehicle>)data[0]; //put list from object in here List <Service> serviceData = (List <Service>)data[1]; List <Journey> journeyData = (List <Journey>)data[2]; //Act //Create Details Details D0 = new Details(vehicleData[0], serviceData, journeyData); Details D1 = new Details(vehicleData[1], serviceData, journeyData); Details D2 = new Details(vehicleData[2], serviceData, journeyData); //Assert //Check Vehicles Details Assert.AreEqual(30500, D0.getTotDistance()); Assert.AreEqual(19000, D1.getTotDistance()); Assert.AreEqual(11000, D2.getTotDistance()); }
public void Details_CheckRevenueInfo_AssertsEqualsTrue() { //Arrange //Get data fom SQL Object[] data = SQLConnector.LoadAll("user id = cars; persistsecurityinfo = True; server = localhost; database = cars_test; password=Password1;"); List <Vehicle> vehicleData = (List <Vehicle>)data[0]; //put list from object in here List <Service> serviceData = (List <Service>)data[1]; List <Journey> journeyData = (List <Journey>)data[2]; //Act //Create Details Details D0 = new Details(vehicleData[0], serviceData, journeyData); Details D1 = new Details(vehicleData[1], serviceData, journeyData); Details D2 = new Details(vehicleData[2], serviceData, journeyData); //Assert //Check Vehicles Details Assert.AreEqual("300 (with 0 unpaid)", D0.getRevenueInfo()); Assert.AreEqual("579 (with 0 unpaid)", D1.getRevenueInfo()); Assert.AreEqual("731 (with 230 unpaid)", D2.getRevenueInfo()); }