예제 #1
0
        public void CheckForCheckOut()
        {
            var book = new Book();
            var student = new Student();

            LibraryManager mgr = new LibraryManager();
            var library = mgr.CheckOutBook(book, student, DateTime.Parse("9/05/2004"));
            List<Library> libraries = new List<Library>();

            Assert.AreEqual(DateTime.Parse("9/05/2004"), library.BorrowDate);
            Assert.AreEqual(DateTime.Parse("10/05/2004"), library.ExpectedReturnDate);
        }
예제 #2
0
        public void CheckIfAgeIsCaluclatedCorrectly()
        {
            LibraryManager mgr = new LibraryManager();
            var student = new Student();
            const decimal expectedAge = 24m;
            decimal daysOfYear = 365m;

            student.DateOfBirth = DateTime.Now.AddDays((int)(-expectedAge * daysOfYear));

            mgr.AddStudentToList(student);

            Assert.AreEqual(expectedAge, student.Age);
        }
 public Library CheckOutBook(Book b, Student s, DateTime borrowdate)
 {
     var result = new Library();
     //if (libraries.Any())
     //{
     //    result.Id = libraries.Max(x => x.Id) + 1;
     //}
     //else
     //{
     //    result.Id = 1;
     //}
     //result.Book = b;
     //result.Student = s;
     result.BorrowDate = borrowdate;
     result.ExpectedReturnDate = borrowdate.AddMonths(1);
     //libraries.Add(result);
     return result;
 }
 public void AddStudentToList(Student s)
 {
     s.Age = (int) (DateTime.Now.Subtract(s.DateOfBirth).TotalDays) / 365;
 }