public void should_pick_nothing_with_ticket_if_stored_nothing()
        {
            var locker = new Locker(1);

            var ticket = locker.Store(null);
            var bag = locker.Pick(ticket);
            Assert.Null(bag);
        }
        public void should_return_ticket_after_store_a_bag_into_locker()
        {
            var locker = new Locker(1);
            var bag = new Bag();

            Ticket ticket = locker.Store(bag);
            Assert.NotNull(ticket);
        }
 public void should_be_able_to_store_after_pick_from_full_locker()
 {
     var locker = new Locker(1);
     var ticket = locker.Store(new Bag());
     locker.Pick(ticket);
     Ticket ticket2 = locker.Store(new Bag());
     Assert.NotNull(ticket2);
 }
        public void should_failed_if_pick_with_not_matched_ticket()
        {
            var locker = new Locker(1);
            locker.Store(new Bag());

            var bag = locker.Pick(new Ticket());
            Assert.Null(bag);
        }
        public void should_return_null_when_locker_is_full()
        {
            var locker = new Locker(1);
            locker.Store(new Bag());

            var bag = new Bag();
            var ticket = locker.Store(bag);
            Assert.Null(ticket);
        }
        public void should_store_bag_in_max_vacancy_locker()
        {
            var locker1 = new Locker(2);
            var locker2 = new Locker(1);
            var lockers = new List<Locker> {locker1, locker2};
            locker1.Store(new Bag());

            var superRobot = new SuperRobot(lockers);
            superRobot.Store(new Bag());
            Assert.False(locker2.IsAvailable);
        }
 private bool TryPick(Locker locker, Ticket ticket, out Bag bag)
 {
     try
     {
         bag = locker.Pick(ticket);
         return(true);
     }
     catch (InvalidOperationException)
     {
         bag = null;
         return(false);
     }
 }
        public void should_pick_the_bag_stored_in_locker_with_ticket()
        {
            var locker = new Locker(2);
            var expectedBag1 = new Bag();
            var expectedBag2 = new Bag();
            var ticket1 = locker.Store(expectedBag1);
            var ticket2 = locker.Store(expectedBag2);

            var bag1 = locker.Pick(ticket1);
            var bag2 = locker.Pick(ticket2);
            Assert.Equal(expectedBag1, bag1);
            Assert.Equal(expectedBag2, bag2);
        }
        public void should_select_the_locker_with_most_boxes_when_store_a_bag()
        {
            var locker1 = new Locker(2);
            var locker2 = new Locker(2);
            var lockers = new List<Locker>{locker1, locker2};

            var robot = new SmartRobot(lockers);

            robot.Store(new Bag());
            var ticket = robot.Store(new Bag());

            Assert.NotNull(locker2.Pick(ticket));
        }
        public void should_return_ticket_after_store_nothing_into_locker()
        {
            var locker = new Locker(1);

            Ticket ticket = locker.Store(null);
            Assert.NotNull(ticket);
        }
 public void should_be_able_to_store_multiple_bags_in_one_locker()
 {
     var locker = new Locker(10);
     locker.Store(new Bag());
     Assert.NotNull(locker.Store(new Bag()));
 }
Exemple #12
0
 protected virtual bool GetLocker(Locker l)
 {
     return(l.AvailableBoxesNumber == Lockers.Max(lo => lo.AvailableBoxesNumber));
 }
 protected override bool GetLocker(Locker l)
 {
     return l.GetVacancy() == Lockers.Max(lo => lo.GetVacancy());
 }
 protected virtual bool GetLocker(Locker l)
 {
     return l.AvailableBoxesNumber == Lockers.Max(lo => lo.AvailableBoxesNumber);
 }
Exemple #15
0
 protected override bool GetLocker(Locker l)
 {
     return(l.GetVacancy() == Lockers.Max(lo => lo.GetVacancy()));
 }