Ejemplo n.º 1
0
 private void EnforceInvariants(HotelRoomSummary rooms)
 {
     if (rooms.NumberOfSingleRooms < 1 && 
         rooms.NumberOfDoubleRooms < 1 && 
         rooms.NumberOfFamilyRooms < 1)
         throw new HotelsMustHaveRooms();
 }
Ejemplo n.º 2
0
 public Hotel(Guid id, HotelAvailability initialAvailability, HotelRoomSummary rooms)
 {
     EnforceInvariants(rooms);
     this.Id = id;
     this.Availability = initialAvailability;
     this.Rooms = rooms;
 }
 public Hotel(Guid id, HotelAvailability initialAvailability, HotelRoomSummary rooms)
 {
     EnforceInvariants(rooms);
     this.Id           = id;
     this.Availability = initialAvailability;
     this.Rooms        = rooms;
 }
 private void EnforceInvariants(HotelRoomSummary rooms)
 {
     if (rooms.NumberOfSingleRooms < 1 &&
         rooms.NumberOfDoubleRooms < 1 &&
         rooms.NumberOfFamilyRooms < 1)
     {
         throw new HotelsMustHaveRooms();
     }
 }
Ejemplo n.º 5
0
        public void Hotels_must_have_rooms_else_they_are_not_hotels()
        {
            var id = Guid.NewGuid();
            var availability = new HotelAvailability(null, null, null);
            
            try
            {
                var rooms = new HotelRoomSummary(0, 0, 0);
                new Hotel(id, availability, rooms);
            }
            catch (HotelsMustHaveRooms hmr)
            {
                // if exception is thrown test passes
                return;
            }

            Assert.Fail("Hotels must have rooms invariant not enforced");
            
        }