public void BookSlot_Can_Put_Correct_Airplane_In_Large_Slot()
        {
            var jumbo = new Jumbo {
                Name = "A380"
            };
            var slot = _airplanePark.FindSlot(jumbo);

            _airplanePark.BookSlot(slot, jumbo);
            _airplanePark.LargeSlots.Count(theSlot => !theSlot.IsAvailable).Should().Be(1);
        }
Exemplo n.º 2
0
        public void BookSlot(Slot slot, Airplane plane)
        {
            if (slot == null)
            {
                throw new ArgumentNullException();
            }

            if (plane == null)
            {
                throw new ArgumentNullException();
            }

            // TODO: Change to accommodate smaller planes in larger slots
            slot.IsAvailable = plane switch
            {
                Jumbo jumbo => false,
                Jet jet => false,
                Prop prop => false,
                      _ => throw new UnknownPlaneException("Plane type not recognised")
            };
        }
    }
Exemplo n.º 3
0
        public Slot FindSlot(Airplane plane)
        {
            if (plane == null)
            {
                throw new ArgumentNullException(nameof(plane));
            }

            // TODO: Change to accommodate smaller planes in larger slots
            Slot availableSlot = plane switch
            {
                Jumbo jumbo => LargeSlots.ToList().Find(slot => slot.IsAvailable),
                Jet jet => MediumSlots.ToList().Find(slot => slot.IsAvailable),
                Prop prop => SmallSlots.ToList().Find(slot => slot.IsAvailable),
                _ => throw new UnknownPlaneException("Plane type not recognised")
            };

            if (availableSlot == null)
            {
                throw new NoRequiredSlotException("There are no slots available for this type of plane");
            }

            return(availableSlot);
        }