public void Driver_GetTotalMiles_TripsAllZero() { //Arrange var driver = new Driver("John"); var startTime = TimeSpan.ParseExact("11:35", "h\\:mm", CultureInfo.InvariantCulture); var endTime = TimeSpan.ParseExact("11:45", "h\\:mm", CultureInfo.InvariantCulture); //Act driver.AddTrip(startTime, endTime, 0.0); driver.AddTrip(startTime, endTime, 0.0); //Assert Assert.AreEqual(0, driver.GetTotalMiles()); }
public void Initialize() { testTrip1 = new Trip("Test1", "9:00", "15:00", "120"); Trip testTrip2 = new Trip("Test1", "12:00", "20:00", "480"); Trip testTrip3 = new Trip("Test1", "0:00", "23:00", "2300"); Trip testTrip4 = new Trip("Test1", "0:00", "0:00", "0"); testDriver1 = new Driver("Test1"); testDriver1.AddTrip(testTrip1); testDriver1.AddTrip(testTrip2); testDriver1.AddTrip(testTrip3); testDriver1.AddTrip(testTrip4); testDriver2 = new Driver("Test2"); }
public void Setup() { driver = new Driver(); driver.Name = "Bob"; Trip trip = new Trip(); trip.StartTime = DateTime.Now; trip.EndTime = DateTime.Now.AddMinutes(60); trip.MilesDriven = 30; driver.AddTrip(trip); trip = new Trip(); trip.StartTime = DateTime.Now; trip.EndTime = DateTime.Now.AddMinutes(60); trip.MilesDriven = 65; driver.AddTrip(trip); }
public void Driver_GetAverageSpeed_TwoTrips() { //Arrange var driver = new Driver("John"); var startTimeTrip1 = TimeSpan.ParseExact("07:15", "h\\:mm", CultureInfo.InvariantCulture); var endTimeTrip1 = TimeSpan.ParseExact("07:45", "h\\:mm", CultureInfo.InvariantCulture); var startTimeTrip2 = TimeSpan.ParseExact("06:12", "h\\:mm", CultureInfo.InvariantCulture); var endTimeTrip2 = TimeSpan.ParseExact("06:32", "h\\:mm", CultureInfo.InvariantCulture); //Act driver.AddTrip(startTimeTrip1, endTimeTrip1, 17.3); driver.AddTrip(startTimeTrip2, endTimeTrip2, 21.8); //Assert Assert.AreEqual(47, driver.GetAverageSpeed()); }
public void AddTrip_Increases_TripHistory_Count() { Assert.AreEqual(0, testDriver2.TripHistory.Count); testDriver2.AddTrip(testTrip1); Assert.AreEqual(1, testDriver2.TripHistory.Count); CollectionAssert.Contains(testDriver2.TripHistory, testTrip1); }
public void Driver_GetAverageSpeed_ElapseTimeIsZero() { //Arrange var driver = new Driver("John"); var startTime = TimeSpan.ParseExact("11:35", "h\\:mm", CultureInfo.InvariantCulture); driver.AddTrip(startTime, startTime, 234); //Act var averageSpeed = driver.GetAverageSpeed(); //Assert }
public void Driver_GetAverageSpeed_OneTrip() { //Arrange var driver = new Driver("John"); var startTime = TimeSpan.ParseExact("12:01", "h\\:mm", CultureInfo.InvariantCulture); var endTime = TimeSpan.ParseExact("13:16", "h\\:mm", CultureInfo.InvariantCulture); //Act driver.AddTrip(startTime, endTime, 42.0); //Assert Assert.AreEqual(34, driver.GetAverageSpeed()); }