public void should_get_error_message_when_manager_is_full() { //Given var bagKeepers = new List<IBagKeeper>(); IBagKeeper lockerForManager = new Locker(1); lockerListForRobot = new List<IBagKeeper>(); lockerListForRobot.Add(new Locker(1)); var lockerListForSmartRobot = new List<IBagKeeper>(); lockerListForSmartRobot.Add(new Locker(1)); var lockerListForSuperRobot = new List<IBagKeeper>(); lockerListForSuperRobot.Add(new Locker(1)); robot = new Robot(lockerListForRobot); var smartRobot = new SmartRobot(lockerListForSmartRobot); var superRobot = new SuperRobot(lockerListForSuperRobot); bagKeepers.Add(smartRobot); bagKeepers.Add(superRobot); bagKeepers.Add(lockerForManager); bagKeepers.Add(robot); manager = new Manager(bagKeepers); //When for (int i = 0; i < 4; i++) { manager.Store(new Bag()); } //Then var ex = Assert.Throws<ArgumentException>(() => manager.Store(new Bag())); Assert.That(ex.Message, Is.EqualTo("The manager is full!")); }
public void should_select_the_highest_vacancy_rate_locker_when_store_bag() { var locker1 = new Locker(3); var locker2 = new Locker(2); var superRobot = new SuperRobot( new List<IBagKeeper> { locker1, locker2 }); locker1.Store(new Bag()); var bag = new Bag(); Ticket ticket = superRobot.Store(bag); Assert.AreSame(bag, locker2.Pick(ticket)); }
public void should_vacancy_rate_be_0_when_with_no_locker() { var lockerWithoutBoxes = new Locker(0); Assert.AreEqual(0, lockerWithoutBoxes.VacancyRate); }
public void should_manage_robots_and_lockers_to_store_bag() { //Given var bagKeepers = new List<IBagKeeper>(); locker = new Locker(1); IBagKeeper lockerForManager = new Locker(1); lockerListForRobot = new List<IBagKeeper>(); lockerListForRobot.Add(locker); robot = new Robot(lockerListForRobot); bagKeepers.Add(lockerForManager); bagKeepers.Add(robot); manager = new Manager(bagKeepers); //When Ticket ticket = manager.Store(bag); Ticket ticket2 = manager.Store(bag2); //Then Assert.NotNull(ticket); Assert.NotNull(ticket2); Assert.AreSame(bag, manager.Pick(ticket)); Assert.AreSame(bag2, manager.Pick(ticket2)); }