public void CantRentIfLate() { idtMock.Now().Returns(new DateTime(2010, 10, 10)); sut.AddRental("Rambo", "1992-11-01"); idtMock.Now().Returns(new DateTime(2010, 10, 10).AddDays(4)); Assert.Throws <DueDateExpiredExeption>(() => sut.AddRental("Rambo2", "1992-11-01")); }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (cmbTenant.SelectedItem == null) { cmbTenant.Focus(); return; } if (dtpDateStart.SelectedDate == null) { dtpDateStart.Focus(); return; } if (dtpDateEnd.SelectedDate == null) { dtpDateEnd.Focus(); return; } if (reasonForEntry == ReasonForEntry.newRental) { selectedRental = new Rental(); // don't forget to add new object to list! rentals.AddRental(selectedRental); } selectedRental.HolidayTenant = (Tenant)cmbTenant.SelectedItem; selectedRental.HolidayResidence = selectedResidence; selectedRental.DateStart = (DateTime)dtpDateStart.SelectedDate; selectedRental.DateEnd = (DateTime)dtpDateEnd.SelectedDate; selectedRental.IsDeposidPaid = (bool)chkDepositPaid.IsChecked; selectedRental.ToPay = CalculateTotalToPay(); decimal.TryParse(txtPaid.Text, out decimal paid); selectedRental.Paid = paid; refreshRequired = true; this.Close(); }
public void CanAddARental() { string title = "Jesus super star"; string socialNumber = "1979-01-01"; sut.AddRental(title, socialNumber); Assert.AreEqual(1, sut.GetRentalsFor(socialNumber).Count); }