public Library CheckOutBook(Book book, Student student, DateTime checkedOutDate) { var result = new Library(); result.ExpectedReturnDate = checkedOutDate.AddMonths(1); result.CheckOutDate = checkedOutDate; return result; }
public void CheckedOutBookDatesSetCorrectly() { LibraryManager mgr = new LibraryManager(); var checkoutdate = new DateTime(2005, 5, 5); var book = new Book(); var student = new Student(); Library result = mgr.CheckOutBook(book, student, checkoutdate); Assert.AreEqual(checkoutdate, result.CheckOutDate); Assert.AreEqual(checkoutdate.AddMonths(1), result.ExpectedReturnDate); }
public void CalculateAge() { Student bob = new Student(); //bob.Name = "Bob Anderson"; bob.DoB = new DateTime(1981, 6, 6); //formulate a dob based off today's date bob.DoB = DateTime.Now.AddDays(-365 * 45); LibraryManager mgr = new LibraryManager(); mgr.AddStudent(bob); Assert.AreEqual(45, bob.Age); }
public void AddStudent(Student s) { s.Age = s.Age = (int)(DateTime.Now.Subtract(s.DoB).TotalDays / 365); }