public void BookingCollectionGetByIDReturnsNullOnNoBookingFound() { BookingCollection testCollection = new BookingCollection(); Date mockDate = Substitute.For <Date>(12, 9, 2019); Time mockTime = Substitute.For <Time>(12, 54); IVenue mockVenue = Substitute.For <IVenue>(); Client mockClient = Substitute.For <Client>("123", "CompanyName1", "CompanyAddress1"); Booking booking1 = new Booking("1", BookingType.FACILITATED, mockClient, mockDate, mockTime, mockVenue); Booking booking2 = new Booking("2", BookingType.FACILITATED, mockClient, mockDate, mockTime, mockVenue); testCollection.Add(booking1); testCollection.Add(booking2); Assert.AreEqual <Booking>(null, testCollection.GetByID("3")); }
public void BookingCollectionDeleteIDSuccess() { BookingCollection testCollection = new BookingCollection(); Date mockDate = Substitute.For <Date>(12, 9, 2019); Time mockTime = Substitute.For <Time>(12, 54); IVenue mockVenue = Substitute.For <IVenue>(); Client mockClient = Substitute.For <Client>("123", "CompanyName1", "CompanyAddress1"); Booking booking1 = new Booking("1", BookingType.FACILITATED, mockClient, mockDate, mockTime, mockVenue); Booking booking2 = new Booking("2", BookingType.FACILITATED, mockClient, mockDate, mockTime, mockVenue); testCollection.Add(booking1); testCollection.Add(booking2); testCollection.DeleteID("1"); Assert.AreEqual <int>(1, testCollection.GetSize()); Assert.IsTrue(testCollection.Contains(booking2)); }
public void BookingCollectionGetClientBookingsReturnsEmptyList() { BookingCollection testCollection = new BookingCollection(); Date mockDate = Substitute.For <Date>(12, 9, 2019); Time mockTime = Substitute.For <Time>(12, 54); IVenue mockVenue = Substitute.For <IVenue>(); Client client1 = new Client("123", "CompanyName1", "CompanyAddress1"); Client client2 = new Client("456", "CompanyName2", "CompanyAddress2"); Booking booking1 = new Booking("1", BookingType.FACILITATED, client1, mockDate, mockTime, mockVenue); Booking booking2 = new Booking("2", BookingType.FACILITATED, client1, mockDate, mockTime, mockVenue); testCollection.Add(booking1); testCollection.Add(booking2); Assert.AreEqual(0, testCollection.GetClientBookings(client2).Count); Assert.IsInstanceOfType(testCollection.GetClientBookings(client1), typeof(BookingCollection)); }
public void AddVoyage(Voyage voyage) { if (voyage != null && !HasVoyage(voyage)) { BookingCollection.Add( new Booking() { Passenger = this, Voyage = voyage } ); } }
public void AddPerson(Passenger Passenger) { if (Passenger != null && !HasPerson(Passenger) && !Gone()) { BookingCollection.Add( new Booking() { Passenger = Passenger, Voyage = this } ); RemainingSeat--; } }
public static BookingCollection GetAllBookings() { BookingCollection bookings = new BookingCollection(); try { using (DatabaseEntities context = new DatabaseEntities()) { IQueryable <Booking> query = from booking in context.Bookings where (booking.confirmed == false) select booking; foreach (Booking booking in query) { Client client = GetClient(booking.clientID); if (client == null) { throw new Exception("Null returned for client"); } booking.client = client; IActivity activity = GetActivity(booking.activityID); if (activity == null) { throw new Exception("Null returned for activity"); } booking.activity = activity; IVenue venue = GetVenue(booking.venueID); if (venue == null) { throw new Exception("Null returned for venue"); } booking.venue = venue; booking.SetDateAndTime(); bookings.Add(booking); } } } catch (Exception exception) { ShowErrorMessage(exception); } return(bookings); }