public Reservation(Client client, Room room, DayDuration duration) { Client = client; Room = room; SetDuration(duration); Guests = new HashSet<Guest>(); }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); Initer.Init(@"Server=ADWA;Database=Hotel;Trusted_Connection=true"); var clientData = new ClientData("test", "test", "test", "test"); var client = new Client { ClientData = clientData }; var repo = new ClientRepository(); repo.Save(client); var features = new List<Feature>(); features.Add(Feature.Bathroom); var room = new Room { Quality = RoomQuality.Average, Features = features, Type = RoomType.HotelRoom }; room.SetCapacity(5); var roomRepo = new RoomRepository(); roomRepo.Save(room); var features2 = new List<Feature>(); features2.Add(Feature.Bathroom); features2.Add(Feature.Tv); var room2 = new Room { Quality = RoomQuality.Good, Features = features2, Type = RoomType.HotelRoom }; room2.SetCapacity(2); roomRepo.Save(room2); var duration = new DayDuration(DateTime.Now, DateTime.Now.AddDays(1)); var reservation = new Reservation(client, room, duration); var reservationRepo = new ReservationRepository(); reservationRepo.Save(reservation); }
public void Duration_must_be_at_least_one_day(DateTime start, DateTime end) { var duration = new DayDuration(start, end); Action a = () => new Reservation(null, null, duration); a.ShouldThrow<ArgumentOutOfRangeException>(); }
public void Cant_add_two_same_guests() { var duration = new DayDuration(new DateTime(2016, 2, 10), new DateTime(2016, 2, 11)); var reservation = new Reservation(null, null, duration); var guestOne = new Guest("Test", "Test"); var guestTwo = new Guest("Test", "Test"); reservation.AddGuest(guestOne); reservation.Invoking(x => x.AddGuest(guestTwo)).ShouldThrow<InvalidOperationException>(); }
public void Duration_is_zero(DateTime start, DateTime end, int expectedDays) { var duration = new DayDuration(start, end); duration.Days.Should().Be(expectedDays); }
public void Duration_is_zero(DateTime start, DateTime end) { var duration = new DayDuration(start, end); duration.Days.Should().Be(0); }
public virtual void SetDuration(DayDuration duration) { if(duration.Days == 0) throw new ArgumentOutOfRangeException(); Duration = duration; }